发布网友 发布时间:2024-10-24 02:17
共1个回答
热心网友 时间:2024-11-06 16:27
#include<stdio.h>
int main(void)
{
double a,b;
char op;
printf("输入一个表达式");
scanf("%lf%c%lf",&a,&op,&b);
switch(op)
{
case'+':
printf("=%.2f\n",a+b);
break;
case'-':
printf("=%.2f\n",a-b);
break;
case'*':
printf("=%.2f\n",a*b);
break;
case'/':
if (b!=0)
printf("=%.2f\n",a/b);
else printf("错误");
break;
default:
printf("错误");
break;
}
return 0;
}