Chinaunix首页 | 论坛 | 博客

分类: 信息化

2014-12-15 11:00:59

#include


double calculetor(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");
  }
  else
  {
   return a/b;
  }
 }
 else
 {
  printf("亲,这个问题太难了,我也不会算\n");
 }
}
 int main()
 {
  double a,b;
  char myoperator;
  scanf("%lf %c %lf",&a,&myoperator ,&b);
  printf("%lf\n",calculetor(a,b,myoperator));
  return 0;
 }
 
如图:

阅读(1354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~