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

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
hndxwyj 1年前 已收到1个回答 举报

与爱神失之交臂 幼苗

共回答了8个问题采纳率:100% 举报

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++语法,应该也是这样的.

1年前

3
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.138 s. - webmaster@yulucn.com