怎么跳出这个无限循环 我的这个if不行啊

来源:百度知道 编辑:UC知道 时间:2024/09/28 13:20:08
#include<stdio.h>
#include<ctype.h>

int main(void)
{
double number1=0;
double number2=0;
char operation=0;
char back=0;

for(;;)
{
printf("\nEnter the calculation\n");
scanf("%lf""%c""%lf",&number1,&operation,&number2);
switch(operation)
{
case'+':
printf("\n=%lf\n",number1+number2);
break;

case'-':
printf("\n=%lf\n",number1-number2);
break;
case'*':
printf("\n=%lf\n",number1*number2);
break;
case'/':
if(number2==0)printf("\n\aYou zhu a ni !");
else
printf("\n=%lf\n",number1/number2);
break;
case'%':
if((long)num

不要用for(;;)这种永真循环,因为你break只是break出switch语句,并没有跳出循环,建议使用while(running)这种循环,让一开始running为TRUE,一旦需要跳出的话只要设置running为FALSE即可