#include
double calculator(double a, double b, char operator)
{
if (operator=='+')
{
return a+b;
}
else if (operator=='-')
{
return a-b;
}
else if (operator=='*')
{
return a*b;
}
else if (operator=='/')
{
if(b==0)
{
printf(" 输入的有误,除数不能为零\n");
}
else
{
return a/b;
}
}
else
{
printf("输入错误\n");
return 0;
}
}
int main()
{
double sum,a,b;
char operator;
scanf("%lf%c%lf",&a,&operator,&b);
printf("%lf\n",calculator(a,b, operator));
return 0;
}
阅读(1024) | 评论(0) | 转发(0) |