![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/781221165066115.png "#left")
#include "stdio.h"
int main( ) {
float d1,d2;char d3;
printf("请输入两个数和运算符号\n");
scanf("%f%c%f",d1,d3,d2);
switch(d3){
case '+':printf("%.2f+%.2f=%.2f\n",d1,d2,d1+d2);break;
case '-':printf("%.2f-%.2f=%.2f\n",d1,d2,d1-d2);break;
case '*':printf("%.2f*%.2f=%.2f\n",d1,d2,d1*d2);break;
case '/':if(d2==0) printf("除数不能为0\n");
else printf("%.2f/%.2f=%.2f",d1,d2,d1/d2);break;
default:
printf("请输入正确的运算符");
break;
}
}