分类: C/C++
2014-12-15 11:32:45
#include
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));
}