信息学奥赛一本通: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;
}
本文来自博客园,作者:I'm_江河湖海,转载请注明原文链接:https://www.cnblogs.com/jhhh/p/16760639.html