忽略优先级的计算器问题
#include<stdio.h> int main()
{
int value1,value2,result,result1,result2,result3,result4;
char op;
printf("请输入算式;");
scanf("%d%c%d",&value1,&op,&value2);
while(op!='='){
if(op=='+'){
result1=value1+value2;
scanf("%d",result1);
}
else if(op=='-'){
result2=value1-value2;
scanf("%d",result2);
}
else if(op=='*'){
result3=value1*value2;
scanf("%d",result3);
}
else if (op=='/'){
result4=value1/value2;
scanf("%d",result4);
}
}
result=result1+result2+result3+result4;
scanf("%d",&result);
printf("result=%d",result);
return 0;
}
/*我的循环不能正常退出,多谢大牛指点*/