#define _CRT_SECURE_NO_WARNINGS 1 //4.枚举常量 ?? ?//枚举-一一列举 ?? ?// ?? ?//性别:男,女,保密 ?? ?//三原色:红,黄,蓝 ?? ?//星期:1 2 3 4 5 6 7? ?? ?//
?? ?//枚举关键字-enum
#include<stdio.h>
enum Sex? { ?? ?MALE, ?? ?FEMALE, ?? ?SECRET }; enum Color { ?? ?BULE, ?? ?RED, ?? ?YELLOW }; //MALE,FEMALE,SECRET-枚举常量 int main()? { ?? ?enum Sex s = FEMALE; ?? ?printf("%d\n",MALE);//0 ?? ?printf("%d\n", FEMALE);//1 ?? ?printf("%d\n", SECRET);//2
?? ?enum Color color = BULE; ?? ?printf("%d\n", RED);//1 ?? ?printf("%d\n", BULE);//0 ?? ?printf("%d\n", YELLOW);//2
?? ?return 0;
} ?
#define _CRT_SECURE_NO_WARNINGS 1
//4.枚举常量
//枚举-一一列举
//
//性别:男,女,保密
//三原色:红,黄,蓝
//星期:1 2 3 4 5 6 7
//
//枚举关键字-enum
#include<stdio.h>
enum Sex
{
MALE,
FEMALE,
SECRET
};
enum Color
{
BULE,
RED,
YELLOW
};
//MALE,FEMALE,SECRET-枚举常量
int main()
{
enum Sex s = FEMALE;
printf("%d\n",MALE);//0
printf("%d\n", FEMALE);//1
printf("%d\n", SECRET);//2
enum Color color = BULE;
printf("%d\n", RED);//1
printf("%d\n", BULE);//0
printf("%d\n", YELLOW);//2
return 0;
}
|