这段c++代码有什么问题?

What is wrong with this C++ code

本文关键字:问题 什么 c++ 代码 这段      更新时间:2023-10-16

我是编程新手,我决定尝试制作一个计算器,可以做简单算术以外的事情。我还没有完成,我只是测试看看它是否工作到目前为止。当我运行它的时候,通过按1的算术键它就停止了。有人能告诉我我做错了什么吗?谢谢你。

#include <iostream>
using namespace std;
int main()
{
    int frsnum
    int secnum
    int arithchoice;
    int answer;
    int x;
    cout << "Welcome to the advanced calculator!" << endl;
    cout << "What are you trying to calculate: Simple Arithmetic < 1 >" << endl;
    cout << "                                  Systems of Equations < 2 >" << endl;
    cout << "                                  Matrices < 3 >" << endl;
    cin >> x;
    if(x == 1)
        {
            cout << "Add <1>|Subtract <2>|Multiply <3>|Divide <4>";
            cin << arithchoice;
        }
    if(arithchoice == 1)
        {
            cout << "Whats the first number: "
            cin >> frsnum;
            cout << "And the second number: "
            cin >> secnum;
            answer = frsnum + secnum;
            cout << "That would be: " answer << endl
        }

    system("PAUSE");
    return 0;
}

语句中的箭头不正确。

cin << arithchoice;

应该被下面的语句

代替
cin>> arithchoice;

更新

记住与Cin和Cout一起使用哪个箭头的最好方法是,当输入值时,您从外部指向计算机。类似地,对于cout,您将值从计算机抛出到外部世界。

现在如果你想把现实世界的值传递给计算机你会用哪个箭头>> cin同样,从计算机到现实世界的结果(用户)"& lt; & lt;"

              ----------------
              |               |
Real world    | <--- computer |
              |_______________|

我注意到的第一件事是,在(x==1) if块中,cin的箭头是错误的。