Chinaunix首页 | 论坛 | 博客

分类: 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));
}

阅读(1476) | 评论(0) | 转发(0) |
0

上一篇:乘法表

下一篇:求根

给主人留下些什么吧!~~