简易计算器
#include <stdio.h>
#include <stdlib.h>
int Add(int x, int y){
return x + y;
}
int Sub(int x, int y){
return x - y;
}
int Mul(int x, int y){
return x * y;
}
int Div(int x, int y){
return x / y;
}
int Res(int x, int y){
return x % y;
}
void calc(){
char i;
scanf("%c", &i);
int x, y;
scanf("%d", &x);
scanf("%d", &y);
switch (i) {
case'+':printf("进行的加法运算结果是:%d\n", Add(x, y)); break;
case'-':printf("进行的减法运算结果是:%d\n", Sub(x, y)); break;
case'*':printf("进行的乘法运算结果是:%d\n", Mul(x, y)); break;
case'/':printf("进行的除法运算结果是:%d\n", Div(x, y)); break;
case'%':printf("进行的取余运算结果是:%d\n", Res(x, y)); break;
}
getchar();
}
int main(){
while (1){
calc();
}
return 0;
}
标签:case,return,运算,int,计算器,break,简易,printf
From: https://www.cnblogs.com/sys2410/p/16758773.html