作业帮 > 综合 > 作业

15、若定义enum color{red,yellow,green=5,blue,white}aa;则执行以下语句后aa

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/07 10:12:56
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
为什么,还有enum
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++语法,应该也是这样的.