多功能计算器代码

太平洋在线下载 85 0

  #include #include using namespace::std; // calculate the expression "lhs oprhs"double calculate(double &, char &,double &);// decide the calculate orderint compare(char, char); int main(void){  char op1, op2;  double lhs, rhs, add;   cout > lhs >> op1 >> rhs)   {     // if op2 is blank, exit the loop     while ((op2 = cin。

  get()) != '

')     {        cin >> add;        // compare the calculate order        // through the if - else, the expression will        // always be "lhs op1 rhs op2 add"        if (compare(op1, op2) >= 0)        {           lhs = calculate(lhs, op1, rhs);           op1 = op2;           rhs = add;        }        else        {           rhs = calculate(rhs, op2, add);        }     }     // output the result as scientific     cout   

标签: 计算器 多功能 代码

抱歉,评论功能暂时关闭!