float a = 0, b = 0, c = 0;
char count = 0;
printf("输入运算\n");
scanf("%f%c%f",&a,&count,&b);
switch (count) {
case'+':{
c = a + b;
}
printf("结果为%.2f",c);
break;
case'-':{
c = a - b;
}
printf("结果为%.2f",c);
case'*':{
c = a * b;
}
printf("结果为%.2f",c);
break;
case'/':{
if (b == 0) {
printf("节操呢");
break;
}
c = a / b;
}
printf("结果为%.2f",c);
break;
default:
break;
}
C语言编译四则运算
最新推荐文章于 2022-09-24 09:52:40 发布