一个空格闹的???求解释。
我是新手,在做一道练习题,做个小计算器程序。要求用到goto实现循环。下面是我的程序:#include<stdio.h>int main(void)
{
double Number1 = 0.0;
double Number2 = 0.0;
char Operation = 0;
char Answer = 0;
start:
printf("\n请输入运算式:\n\t");
scanf("%lf %c %lf",&Number1,&Operation,&Number2);
/*********检测数据的可靠性并输出计算结果********/
switch(Operation)
{
case '+':
printf("\t= %lf\n",Number1 + Number2);
break;
case '-':
printf("\t= %lf\n",Number1 - Number2);
break;
case '*':
printf("\t= %lf\n",Number1 * Number2);
break;
case '/':
if (Number2 == 0)
printf("\a\nERROR!除数不能为0!!\n");
else
printf("\t= %lf\n",Number1 / Number2);
break;
case '%':
if ((long)Number2 == 0)
printf("\a\nERROR!除数不能为0!!\n");
else
printf("\t= %ld\n",(long)Number1 % (long)Number2);
break;
default :
printf("\a\nERROR!错误的运算符号\n");
break;
}
choose:
printf("\n继续计算?Y/N\n");
scanf(" %c",&Answer); /**********求解释********就是这行里的%前的那个空格*******去掉就不能循环了*****/
switch(Answer)
{
case 'Y':case 'y':
goto start;
break;
case 'N':case 'n':
printf("\n谢谢使用,再见!\n");
break;
default:
printf("\n输入错误,请重新选择。(Y/N)\n");
goto choose;
break;
}
return 0;
}