【发布时间】:2014-05-22 23:41:22
【问题描述】:
我是编程新手,我决定尝试制作一个计算器,它可以做简单算术以外的事情。我还没有完成,我只是在测试它是否工作到目前为止。当我运行它并按 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。 -
我注意到的第一件事是
fstnum和secnum的声明周围缺少分号。
标签: c++ calculator