| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1336 人关注过本帖
标题:简单的计算器程序问题
取消只看楼主 加入收藏
fl8962
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:14
帖 子:539
专家分:2471
注 册:2012-10-17
结帖率:96.23%
收藏
已结贴  问题点数:4 回复次数:0 
简单的计算器程序问题
#include<stdio.h>
#include<stdlib.h>
#include <math.h>
int main()
{ float a,b,answer;
char op;
  printf("this is a simple calculator\n");
  printf("first of all, please input the operator,and then input the first number,and then input the other number\n");
  
  scanf("%f",&a);
  scanf("%c",&op);
  scanf("%f",&b);
  if(op=='+')
    {
      answer=a+b;
      printf("%f\n",answer);
    }
  else if(op=='-')
    {
      answer=a-b;
      printf("%f\n",answer);
    }
  else if(op='*')
    {
      answer=a*b;
      printf("%f\n",answer);
    }
  else if(op='/')
    {
      answer=a/b;
      printf("%f",answer);

    }
  return 0;
}
这个是我写的一个简单的计算器程序,不知道为什么运行错误,希望大家指点一下,谢谢。
搜索更多相关主题的帖子: calculator 计算器 include please number 
2014-01-14 09:07
快速回复:简单的计算器程序问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017344 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved