写一个计算器 还有一些bug调试了半天 终于可以了
#include<stdio.h>
{
double a;
double b;
double c;
char s;
printf(" please input num1:\n");
scanf("%f",&a);
getchar();
printf("please input op:\n");
scanf("%c",&s);
printf("please input num2:\n");
scanf("%f",&b);
print ("a = %d, s = %c,b = %d\n ",a,s,b);
switch(s)
{
case '+':
s = a + b;
break;
case '-':
s = a - b;
break;
case '*':
s = a * b;
break;
case '/':
{
if (b == 0)
{
printf("error!\n");
break;
}
else
{
s = a / b;
}
break;
}
default:
printf("error!\n");
}
printf("%d\n",s);
return 0;
}