double getDvision(int x,int y,int z){
return x / y / z;
}
int sum (int x,int y,int z){
return x + y + z;
}
int getMulplication(int x,int y,int z){
return x * y * z;
}
int sub(int x,int y,int z){
return x - y - z;
}
int getMode(int x,int y,int z){
return x % y % z;
}
int main(int argc, const char * argv[]) {
printf("请输入一个数:\n");
int num1;
scanf("%d",&num1);
while (getchar() != '\n');
printf("输入一个字符\n");
char oper;
scanf("%c",&oper);
while(getchar() != '\n');
printf("请输入一个数:\n");
int num2;
scanf("%d",&num2);
while(getchar() != '\n');
printf("输入一个运算符:\n");
char oper2;
scanf("%c",&oper2);
while(getchar() != '\n');
printf("请输入一个数:\n");
int num3;
scanf("%d",&num3);
double res = 0.0;
if (oper == oper2) {
switch (oper) {
case '+':
//printf("")
res = sum(num1, num2,num3);
break;
case '-':
//printf("")
res = sub(num1, num2,num3);
break;
case '*':
//printf("")
res = getMulplication(num1, num2,num3);
break;
case '/':
//printf("")
res = getDvision(num1, num2,num3);
break;
case '%':
//printf("")
res = getMode(num1, num2,num3);
break;
default:printf("输入的运算符错误!\n");
return 0;
}
}else{
printf("本程序员未开发该功能,敬请期待!\n");
return 0;
}
printf("%d %c %d %c %d = %lf\n",num1,oper,num2,oper2,num3,res);
return 0;
}
|
|