c语言之switch语句
#include <stdio.h> int main(void) { int i; scanf("%d",@i); switch (i) { case 1: printf("%d\n", i); break; case 3: printf("%d\n", i); break; case 5: printf("%d\n", i); break; default: printf("*\n"); } getchar(); return 0; }
#include <stdio.h> int main(void) { int i; scanf("%d",@i); switch (i) { case 1: printf("%d\n", i); break; case 3: printf("%d\n", i); break; case 5: printf("%d\n", i); break; } getchar(); return 0; }
#include <stdio.h> int main(void) { int i; scanf("%d",&i); switch (i) { case 1: case 3: case 5: printf("%d\n", i); break; case 4: printf("@\n"); break; default: printf("*\n"); } getchar(); return 0; }
#include <stdio.h> int main(void) { char c; scanf("%c",&c); switch (c) { case 'A': printf("6\n"); break; case 'B': printf("7\n"); break; case 'C': printf("1\n"); break; case 'D': printf("2\n"); break; case 'E': printf("3\n"); break; case 'F': printf("4\n"); break; case 'G': printf("5\n"); break; } getchar(); return 0; }
#include <stdio.h> int main(void) { enum ABCD {AAA,BBB,CCC,DDD} e; e = CCC; switch (e) { case AAA: printf("%d.AAA\n", e); break; case BBB: printf("%d.BBB\n", e); break; case CCC: printf("%d.CCC\n", e); break; case DDD: printf("%d.DDD\n", e); break; default: ; } getchar(); return 0; }