有两个变量a和b,在执行了如下代码后: a = 32768; b = a; printf("%d %d\n", a, b); 输出两个数:32768 -32768。 请问a和b分别是以下哪种类型?(提示:b和a的二进制形式是一样的。无符号数用%d输出结果必然是非负的。b输出为负数,说明其符号位为1)
得分/总分
A.
其他三个选项都不对
B.
unsigned short,short
C.
int,short
D.
unsigned int, int
B
#include <iostream>
using namespace std;
int main()
{
unsigned short a =32768;
short b = a;
printf("%d %d\n", a, b);
return 0;
}
选 C