switch-case:case 1中能不能在调用case
程序代码:
#include <stdio.h> int main(void) { int i; int a,b,c,d,e,f; scanf("%d",&i); switch(i) { case 1: while(10000) { printf("a = "); if(scanf("%d",&a)) { printf("b = "); if(scanf("%d",&b)) { printf("c = %d\n",a+b); printf("\n"); } else break; } else break; } break; case 2: while(10000) { printf("d = "); if(scanf("%d",&d)) { printf("e = "); if(scanf("%d",&e)) { printf("f = %d\n",d+e); printf("\n"); } else break; } else break; } break; default: printf("Error!\n"); } return 0; }
输出显示:
1
a = 6
b = 5
c = 11
a = g
--------------------------------
Process exited after 6.13 seconds with return value 0
请按任意键继续. . .
输入字符
case 1 break 之后能不能 不退出 而是返回 switch 重新开始,
换句话说 case 1 结束后不退出 而是输入 2 调用 case 2