1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include <stdio.h>
enum color { red, yellow = 10, green, blue }; int main(int argc, char *argv[]) { printf("red: %d ,yellow: %d ,green: %d , \n", red, yellow, green); int c = 11; switch (c) { case red: puts("oh red.\n"); break; case yellow: puts("oh yellow.\n"); break; case green: puts("oh green.\n"); break; case blue: puts("oh blue.\n"); break; default: puts("这枚举还没数组好用 坑.\n"); break; } return 0; }
|