#include
void main()
{
float num1,num2;
char ch;
printf("请输入运算符(+-*/):");
scanf("%c",&ch);
printf("请输入第一个数字:");
scanf("%f",&num1);
printf("请输入第二个数字:");
scanf("%f",&num2);
switch(ch)
{
case '+':
printf("%f+%f=%f\n",num1,num2,num1+num2);
break;
case '-':
printf("%f-%f=%f\n",num1,num2,num1-num2);
break;
case '*':
printf("%fx%f=%f\n",num1,num2,num1*num2);
break;
case '/':
printf("%f/%f=%f\n",num1,num2,num1/num2);
break;
default:
printf("错误输入!\n");
break;
}
}
#include
void main()
{
float a,b;char ch;
scanf("%f%c%f",&a,&ch,&b);
switch(ch)
{
case '+': printf("%f",a+b);break;
case '-': printf("%f",a-b);break;
case '*': printf("%f",a*b);break;
case '/':
{
if(b==0) printf("算式无意义");
else
{printf("%f",a/b);break;}
}
default: printf("运算符号有误");
}
}
退格键还真没做过了!