信息学奥赛一本通:1020~1024

1020:打印ASCII码

#include<cstdio>
using namespace std;
int main ()
{
	char a;
	int b;
	scanf("%c",&a);
	b=a;
	printf("%d",b);
	return 0;
}

1021:打印字符

#include<cstdio>
using namespace std;
int main ()
{
	int a;
	char b;
	scanf("%d",&a);
	b=a;
	printf("%c",b);
	return 0;
}

1022:整型与布尔型的转换

#include<cstdio>
using namespace std;
int main ()
{
	int a,b;
	bool c;
	scanf("%d",&a);
	c=a;
	b=c;
	printf("%d",b);
	return 0;
}

1023:Hello,World!的大小

#include<cstdio>
using namespace std;
int main ()
{
	printf("%d",sizeof("Hello, World!"));
	return 0;
}

1024:保留3位小数的浮点数

#include<cstdio>
using namespace std;
int main()
{
	float x;
	scanf("%f",&x);
	
	printf("%.3f",x);
	return 0;
}

posted @ 2022-10-07 20:22  I'm_江河湖海  阅读(74)  评论(0编辑  收藏  举报