若有如下定义,则( ) 是不正确的语句。 enum weekday{ mon,tue,wed,thu,fri } workday;
A: workday=(enum weekday)3;
B: workday=(enum weekday)(4-2);
C: workday=3;
D: workday=thu;
A: workday=(enum weekday)3;
B: workday=(enum weekday)(4-2);
C: workday=3;
D: workday=thu;
举一反三
- 若有如下定义,则 是不正确的语句。 enum weekday{ mon,tue,wed,thu,fri } workday;
- 可以在定义时改变枚举元素的值,如:enum weekday{Sun=7, Mon=1, Tue, Wed, Thu, Fri, Sat}workday
- 有枚举类型的声明:enum WEEKDAY {Sun=7, Mon=1,Tue, Wed, Thu, Fri, Sat} workday;那么以下语句错误的是_____ A: enum WEEKDAY today=Fri;if( today >Fri) printf("Today is weekend!\n"); B: enum WEEKDAY today;today = (enum WEEKDAY)4;if( today >Fri) printf("Today is weekend!\n"); C: enum WEEKDAY today=Fri;tmp=today-2;if( tmp > 0) printf("Today is weekend!\n"); D: today = (enum WEEKDAY)4;if( today-2 > Fri) printf("Today is weekend!\n");
- 有如下定义: enum weekday { sun, mon, tue=4, wed, thu, fri, sat } ; 则元素fri的值为_____________。(填阿拉伯数字)
- 设有定义语句enumworkday{Mon=1,Tue,Wed,Thu,Fri}workday;则枚举常量Tue的值为______。