enum举例
#include<stdio.h>
#include<string.h>
enum day{sun=0,mon,tue,wed,thu,fri,sat};
enum day tomorrow(enum day d)
{
enum day nd; switch(d)
{
case sun: nd=mon;break;
case mon: nd=tue;break;
case tue: nd=wed;break;
case wed: nd=thu;break;
case thu: nd=fri;break;
case fri: nd=sat;break;
case sat: nd=sun;break;
}
return (nd);
}
int main()
{
enum day xx,yy;
char str[5];
printf("please input current date:");
scanf("%s",str);
if(strcmp(str,"sun")==0)xx=sun;
else if(strcmp(str,"mon")==0)xx=mon;
else if(strcmp(str,"tue")==0)xx=tue;
else if(strcmp(str,"wed")==0)xx=wed;
else if(strcmp(str,"thu")==0)xx=thu;
else if(strcmp(str,"fri")==0)xx=fri;
else if(strcmp(str,"sat")==0)xx=sat;
yy=tomorrow(xx);
switch(yy)
{
case sun:printf("tomorrow is sun\n");break;
case mon:printf("tomorrow is mon\n");break;
case tue:printf("tomorrow is tue\n");break;
case wed:printf("tomorrow is wed\n");break;
case thu:printf("tomorrow is thu\n");break;
case fri:printf("tomorrow is fri\n");break;
case sat:printf("tomorrow is sat\n");break;
}
return 0;
}