2024-10-01 17:21:41
//满足要求;如果觉得不好看,想单独做主菜单,你自己可以稍微改改
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,sum;
char c;
while (true)
{
printf("输入格式:数字 运算符 数字: 1+2\n");
scanf("%d%c%d",&a,&c,&b);
switch(c)
{
case '+':
sum=a+b;
printf("=%d\n",sum);
break;
case '-':
sum=a-b;
printf("=%d\n",sum); break;
case '*':
sum=a*b;
printf("=%d\n",sum); break;
case '/':
sum=a/b;
printf("=%d\n",sum); break;
case '%':
sum=a%b;
printf("=%d\n",sum); break;
}
printf("清屏并返回主菜单!\n");
system ("pause");
system("cls"); //清屏
}
return 0;
}