#include
int main()
{int a,b,err=0;
char op;
while(1)
{printf("输入两个整数及一个运算符(+、-、*、/):\n");
scanf("%d%c%d",&a,&op,&b);
switch (op)
{case '+': printf("%d%c%d=%d\n",a,op,b,a+b);break;
case '-': printf("%d%c%d=%d\n",a,op,b,a-b);break;
case '*': printf("%d%c%d=%d\n",a,op,b,a*b);break;
case '/': if(b)printf("%d%c%d=%d\n",a,op,b,a/b);break;
default: err=1; break;
}
if(err)break;
}
return 0;
}
输入: 12 + 34 输出: 46 输入quit 程序退出while #include