其实还可以加个循环输入的,不过怕你输入格式错误,没加了。。。#include
#include
int
main()
{
double
a,b;
char
c;
scanf("%lf%c%lf",&a,&c,&b);
switch(c)
{
case'+':printf("=%g",a+b);break;
case'-':printf("=%g",a-b);break;
case'*':printf("=%g",a*b);break;
case'/':
if(b==0)
{printf("分母不能为零");
break;
}
printf("=%g",a/b);
break;
default:
printf("无解");
break;
}
return
0;
}
其实还可以加个循环输入的,不过怕你输入格式错误,没加了。。。#include
#include
int
main()
{
double
a,b;
char
c;
scanf("%lf%c%lf",&a,&c,&b);
switch(c)
{
case'+':printf("=%g",a+b);break;
case'-':printf("=%g",a-b);break;
case'*':printf("=%g",a*b);break;
case'/':
if(b==0)
{printf("分母不能为零");
break;
}
printf("=%g",a/b);
break;
default:
printf("无解");
break;
}
return
0;
}