#include <stdio.h>
int main (int argc, const char * argv[])
{
char item;
int row;
int size;
int price_list[5][8] =
{
{9,18,27,36,45,54,63,72},
{10,20,30,40,50,60,70,80},
{11,22,33,44,55,66,77,88},
{12,24,36,48,60,72,84,96},
{13,26,39,52,65,78,91,104}
};
do {
printf("Please enter the item:\n");
scanf("%c", &item);
printf("Please enter the size:\n");
scanf("%d", &size);
switch (item) {
case 'e':
row = 0;
break;
case 't':
row = 1;
break;
case 's':
row = 2;
break;
case 'u':
row = 3;
break;
case 'd':
row = 4;
break;
default:
row = 5;
break;
}
if (row < 5) {
printf("%d\n", price_list[row][size]);
}
}
while (item != 'q');
return 0;
}
循环第一次正常运行,然后它一次打印两个printf语句 请输入项目: Ë 请输入尺码: 1 18 请输入项目: 请输入尺寸:
为什么会这样?