C语言程序问题求解,编写一个简单的计算器,要求每次输入加号等之后重新显示界面。为什么每次for循环两次 5
#include<iostream>usingnamespacestd;intmain(){charm;inta=3,b=4;for(m=1;m!=0;){cout<<"...
#include<iostream>using namespace std;int main(){ char m; int a = 3, b = 4; for (m = 1; m != 0;) { cout << "\t\t|--------------------------------------|\n"; cout << "\t\t|\t +:加法 |\n"; cout << "\t\t|\t -:减法 |\n"; cout << "\t\t|\t *:乘法 |\n"; cout << "\t\t|\t /:除法 |\n"; cout << "\t\t|--------------------------------------|\n"; cout << "请输入运算符(+ - * /):"; m = getchar(); switch (m) { case '+':cout << a + b<<endl; break; case '-':cout << a - b<<endl; break; case '*':cout << a*b <<endl; break; case '/':cout << a / b<<endl; break; case '\r':system("cls"); break; } } return 0;}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询