代码
#include<stdio.h>
int main()
{
int a,b,c,d;
do
{
printf("************计算器*****************\n");
printf("***********************************\n");
printf("***********************************\n");
printf("* 1---加法 *\n");
printf("***********************************\n");
printf("* 2---减法 *\n");
printf("***********************************\n");
printf("* 3---乘法 *\n");
printf("***********************************\n");
printf("* 4---除法 *\n");
printf("***********************************\n");
printf("***********0---退出****************\n");
printf("请选择您需要的运算:\n");
scanf("%d",&d);
if (d==1)
{
printf("请输入两个整数相加:\n");
scanf("%d+%d",&a,&b);
c=a+b;
printf("=%d\n",c);
}
if (d==2)
{
printf("请输入两个整数相减:\n");
scanf("%d-%d",&a,&b);
c=a-b;
printf("=%d\n",c);
}
if (d==3)
{
printf("请输入两个整数相乘:\n");
scanf("%d*%d",&a,&b);
c=a*b;
printf("=%d\n",c);
}
if (d==4)
{
printf("请输入两个整数相除:\n");
scanf("%d/%d",&a,&b);
c=a/b;
printf("=%d\n",c);
}
}
while(d!=0);
printf("退出计算器\n");
return 0;
}
运行结果如下