枚举是一个数据类型,可以先定义一个枚举类型后定义变量,或者同时进行
//简单示例代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
enum weekend{monday = 1,tuesday,wednesday,thursday,friday,saturday,sunday};
enum weekend day;
int k;
int i = 0;
for(i = 0; i < 7;i++)
{
printf("\tinput the day you have workded!\n");
scanf("%d",&k);
day = (enum weekend)k;
switch(day)
{
case monday:
printf("fuck!today is monday");
break;
case tuesday:
printf("so good!today is tuesday");
break;
case wednesday:
printf("come on!today is wednesday");
break;
case thursday:
printf("aha!in the middle1 of the week!today is thursday");
break;
case friday:
printf("today is sunday,tomorrow you will have a rest,hah!");
break;
default:
printf("go for a weekend!may you have a good time!");
}
}
return EXIT_SUCCESS;
}
练习玩玩