C++高手帮改进我的这个程序,加急!!!!!

来源:百度知道 编辑:UC知道 时间:2024/07/08 01:12:58
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{char w;
double a,b;
cout <<"请输入表达式";
cin >>a>>w>>b;
if (w=='+')
cout <<a+b<<endl;
if (w=='-')
cout <<a-b <<endl;
if (w=='*')
cout <<a*b <<endl;
if (w=='/')
cout <<a/b <<endl;
return 0;
}
设置一个简单的计算器,w我这个程序,不能连续运行运算,运行一个又要重新执行才能运行下一个计算

//稍微改了下,不要介意
//PS:个人觉得CASE更简洁
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{char w;
double a,b;
while(1)
{
cout <<"请输入表达式";
cin >>a>>w>>b;
if (w=='+') cout <<a+b<<endl;
if (w=='-') cout <<a-b <<endl;
if (w=='*') cout <<a*b <<endl;
if (w=='/') cout <<a/b <<endl;
system("pause");
system("CLS");
}
return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{char w;
double a,b;
while(1)
{
cout <<"请输入表达式";
cin >>a>>w>>b;
if (w=='+') cout <<a+b<<endl;
if (w=='-') cout <<a-b <<endl;
if (w=='*') cout <<a*b <&l