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;
}
But the output block is :
And I am wondering why the note "input operator appeared twice.
'break' should have bring the procedure to the printf statement ,shouldn't they?