点击(此处)折叠或打开
-
#include<stdio.h>
-
-
double calcutotor(double a,double b,char myoperator)
-
{
-
if(myoperator=='+')
-
{
-
return a+b;
-
}
-
else if(myoperator=='-')
-
{
-
return a-b;
-
}
-
else if(myoperator=='*')
-
{
-
return a*b;
-
}
-
else if(myoperator=='/')
-
{
-
if(b==0)
-
{
-
printf("除数不能为零!!\n");
-
return 0;
-
}
-
else
-
{
-
return a/b;
-
}
-
}
-
else
-
{
-
printf("亲,不能这样操作\n");
-
return 0;
-
-
}
-
}
-
int main()
-
{
-
double a,b;
-
char myoperator;
-
scanf("%lf%c%lf",&a,&myoperator,&b);
-
printf("%lf\n" ,calcutotor(a,b,myoperator));
-
return 0;
-
- }