【发布时间】:2014-03-04 17:10:44
【问题描述】:
我已经制作了一个“程序”,只是说欢迎!键入要彼此相加的两个数字: 在那里你输入两个数字然后你得到答案...... 完成后,它会说: Press any key to continue 。 . . 当您按下某个键时,程序会关闭,但我希望它在您按下任何键时重新启动... 我怎么做?我将 Microsoft Visual Studio Express 2013 用于 Windows 桌面... 语言是 C++
这是我的代码:
#include <iostream>
#include <limits>
#include <cstdio>
using namespace std;
int Add(int x, int y)
{
cout << "Calculating the sum of " << x << " + " << y << "\n";
return (x + y);
}
int main()
{
cout << " Welcome!\n";
int a, b, c;
cout << "Type two numbers you want to be added to each other: ";
cin >> a;
cin >> b;
c = Add(a, b);
cout << "The answere is: " << c;
cout << "\nShutting down....\n\n";
system("pause");
return 0;
}
【问题讨论】:
-
在 main() 中使用 while 循环 cplusplus.com/doc/tutorial/control
标签: c++