请大家帮下忙啊!谢谢!
请看下面一个程序:#include <stdio.h>int main(void)
{ int choice, i; double price;
for( i = 1; i <= 5; i++)
{
printf("[1] Select crisps \n");
printf("[2] Select popcorn \n");
printf("[3] Select chocolate \n");
printf("[4] Select cola \n");
printf("[0] exit \n");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1: price=3.0; break;
case 2: price=2.5; break;
case 3: price=4.0; break;
case 4: price=3.5; break;
default: price=0.0; break;
}
printf("price = %0.1f\n", price);
}
printf("Thanks \n");
}
为什么在运行的时候,每输入数字后按回车执行,需一次一次的,直到五次结束。而输入“=”这类字符时,输入第一个敲回车后面的五个都一起出来了?