这段c++代码有什么问题?
What is wrong with this C++ code
我是编程新手,我决定尝试制作一个计算器,可以做简单算术以外的事情。我还没有完成,我只是测试看看它是否工作到目前为止。当我运行它的时候,通过按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
的箭头是错误的。
相关文章:
- 警告处理为错误这里有什么问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 当我尝试添加 2 个大字符串时,我无法弄清楚出了什么问题
- 违反const正确性:我应该现实地期待什么问题
- 这个带有模板<类 Vector 的C++代码片段有什么问题>
- 我的逻辑反转字符串中的元音有什么问题?
- 需要以下代码的帮助,下面的代码有什么问题
- 常量公共成员有什么问题?
- c++无值sort()的问题是什么?
- 以下代码中的函数模板有什么问题?
- 这个返回元素位置的基于循环的函数有什么问题?
- creat_list2功能有什么问题?
- 基本的 c++ 问题:如果我在函数中创建某些内容并返回它会发生什么?
- 我遇到了黑客排名中的问题"TWO STRINGS"的三个测试用例的分段错误。原因是什么?
- 什么是钻石问题?是一系列问题还是特定问题?
- 格式说明符C++有什么问题
- 我应该在 main 函数中写什么来测试我的问题?
- 任何人都可以告诉我我的 C++ 代码出了什么问题?
- 方法问题 - 什么会改变值,什么不会改变?什么是无效的?