- # include <stdio.h>
- void main( )
- {
- enum weekday {sun,mon,tue,wed,thu,fri,sat} day;
- int k;
- printf("input a number(0--6)");
- scanf("%d",&k);
- day=(enum weekday)k;
- switch(day)
- {
- case sun: printf("sunday/n");break;
- case mon: printf("monday/n");break;
- case tue: printf("tuesday/n");break;
- case wed: printf("wednesday/n");break;
- case thu: printf("thursday/n");break;
- case fri: printf("friday/n");break;
- case sat: printf("satday/n");break;
- default: printf("input error/n");break;
- }
- }
复制代码 程序运行结果为:
input a number(0--6)1
monday
|
|