15、若定义enum color{red,yellow,green=5,blue,white}aa;则执行以下语句后aa的值为-—C—————。aa=white;printf(”%d”,aa);(A)white (B)4 (C)7 (D)5
2 回答

阿晨1998
TA贡献2037条经验 获得超6个赞
enum color { red, yellow, green = 5, blue, white }
以C#中,上面的语句是定义枚举类型,是值类型。
枚举类型可转成int型,但需要显示转换,枚举型转成int型时,默认从0开始,但可通过自定义来改变其顺序。
Console.WriteLine((int)color.red); //输出0
Console.WriteLine((int)color.yellow); //输出1
Console.WriteLine((int)color.green ); //输出5
Console.WriteLine((int)color.blue); //输出6
Console.WriteLine((int)color.white); //输出7
看你使用的printf("%d",aa);以vc++语法,应该也是这样的。
- 2 回答
- 0 关注
- 121 浏览
添加回答
举报
0/150
提交
取消