c语言编程练习题:7-98 两个数的简单计算器
作者:yunjinqi   类别:    日期:2023-05-31 10:39:57    阅读:136 次   消耗积分:0 分    

image.png

#include <stdio.h>
#include <math.h>
int main(){
    int a,c;
    char b;
    if (scanf("%d %c %d",&a,&b,&c)!=EOF){
        //printf("%d %c %d",a,b,c);
        if (b == '+'){printf("%d",a+c);}
        else if (b == '-'){printf("%d",a-c);}
        else if (b == '*'){printf("%d",a*c);}
        else if (b == '/'){printf("%d",a/c);}
        else if (b == '%'){printf("%d",a%c);}
        else{printf("ERROR");}
        
    }else{
        printf("input wrong");
    }
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/223
上一篇:c语言编程练习题:7-97 计算个人所得税
下一篇:c语言编程练习题:7-99 打印九九口诀表