回复 7楼 lin5161678
多个换行 但在这里不会导致出错
你用DEV运行一下他原来的程序,看看出不出错;
后面的%f后面的空格倒是有必要删掉
残留给b 看不懂是什么意思
scanf()函数输入完成后,回车符残留在输入缓冲流里的例子,并不少见,运行一个下面这个程序

程序代码:
#include<stdio.h>
int main()
{
int m,e,choice1;
char choice2;
double a,cost;
printf("Enter how much gas a = ");
scanf("%lf",&a);
printf("90# gas seclet 90\n");
printf("93# gas select 93\n");
printf("97# gas select 97\n");
printf("Enter choice1:");
scanf("%d",&choice1);
switch(choice1)
{
case 90#:cost=6.95 * a;break;
case 93#:cost=7.44 * a;break;
case 97#:cost=7.93 * a;break;
default:cost=0.00;break;
}
printf("self-service select m\n");
printf("ancillary-service select e\n");
printf("Enter choice2:");
scanf("%c",&choice2);
if(choice2 == 'm')
{
cost=cost * (1-0.05);
}
else if(choice2 == 'e')
{
cost=cost * (1-0.03);
}
else
printf("\n");
printf("You need pay %.2f yuan\n",cost);
return 0;
}