标题:求助 c语言中编写计算器问题用getchar
取消只看楼主
新手啊啊啊啊
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2015-7-27
结帖率:0
已结贴  问题点数:10 回复次数:1 
求助 c语言中编写计算器问题用getchar
#include<stdio.h>
#include<iostream>
void main()
{
    int a,b,sum;
    char c;
    printf("please input the two number:");
    scanf_s("%d,%d",&a,&b);
    printf("please input you want the oreap:");
    c=getchar();
    if(c=='+')
    {
        sum=a+b;
        printf("the result=%d",sum);
    }
    if(c=='-')
    {
        sum=a-b;
        printf("the result=%d",sum);
    }
    if(c=='*')
    {
        sum=a*b;
        printf("the result=%d",sum);
    }
    if(c=='/')
    {
        sum=a/b;
        printf("the result=%d",sum);
    }
    system("pause");
}


    这是我的代码,但为什么我到getchar后的代码运行不了,可以详细的说明用getchar来编写四则运算的计算器
2015-07-28 10:37
新手啊啊啊啊
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2015-7-27
得分:0 
还有我是用VS2010编写的
2015-07-28 10:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-455847-1-1.html




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

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