关于简易计算器的问题
这一段程序要做到的效果是对任意个数的数据进行基本运算,可是没成功,求赐教!#include<stdio.h>
int main()
{
float a,b,s;
char op = '$';
scanf("%f",&a);
if(op != '=')
{
scanf("%c",&op);
scanf("%f",&b);
switch(op)
{
case '+':s = a + b;break;
case '-':{if(a > b)
s = a - b;
else
s = -(b - a);
} ;break;
case '*':s = a * b;break;
case '/':{if(b == 0)
printf("出错");
else
s = a / b;
};break;
}
a = s;
b = 0;
}
else
printf("%f",a);
}