1 十进制数255表示成四位十六进制形式是:
00FF
2 short类型变量n的值是-12,那么其值的四位十六进制形式是:
FFF4
3 有两个变量a和b,在执行了如下代码后: a = 32768; b = a; printf(“%d %d\n”, a, b); 输出两个数:32768 -32768。 请问a和b分别是以下哪种类型?
#include <stdio.h>
int main(void)
{
unsigned short a1;
short b1;
int a2;
short b2;
unsigned int a3;
int b3;
a1 = 32768;
b1 = a1;
a2 = 32768;
b2 = a2;
a3 = 32768;
b3 = a3;
printf("%d %d\n", a1, b1);
printf("%d %d\n", a2, b2);
printf("%d %d\n", a3, b3);
return 0;
}
unsigned short,short
int,short
4 编程题1: 输出第二个整数
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
printf("%d\n", b);
return 0;
}
5 编程题2: 字符菱形:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char in;
int r, c;
int m[5][5] = { {0,0,1,0,0}, {0,1,1,1,0}, {1,1,1,1,1}, {0,1,1,1,0}, {0,0,1,0,0}};
scanf("%c", &in);
for (r=0; r<5; r++)
{
for (c=0; c<5; c++)
{
if (m[r][c]==0)
printf(" ");
else
printf("%c", in);
}
printf("\n");
}
return 0;
}
6 编程题3: 打印ASCII码:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int c;
scanf("%c", &c);
printf("%d\n", c);
return 0;
}
7 编程题4:打印字符:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int i;
scanf("%u", &i);
printf("%c\n", i);
return 0;
}
8 编程题5: 整型数据类型存储空间大小:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int i=0;
short s=0;
printf("%d %d\n", sizeof(i), sizeof(s));
return 0;
}
4 2
9 编程题6: 浮点型数据类型存储空间大小:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
float f=0;
double d=0;
printf("%d %d\n", sizeof(f), sizeof(d));
return 0;
}
4 8
-eof-