int main() {
// insert code here...
char ch; //the operator
int c, t, h ; //the weight of the three items
int flag = 1; //note for iteration ending
while (flag == 1) {
printf("input operator:");
ch = getchar();
switch (ch) {
case 'a':
printf("input the weight of chaoxianji:");
scanf("%d", &c);
break;
case 'b':
printf("input the weight of tiancai:");
scanf("%d", &t);
break;
case 'c':
printf("input the weight of huluobo:");
scanf("%d", &h);
break;
case 'q':
flag = 0; // get out of cycle
break;
}
}
return 0;
}
但输出块是:
我想知道为什么注释“输入操作符出现两次。
'break'应该把程序带到printf语句,不应该吗?