我做了一個「程序」,只是說歡迎!鍵入你想要添加到對方的兩個號碼: 那裏你輸入兩個數字,然後你得到答案了...... 當這樣做完成後,它說:按任意鍵繼續。 。 。 當您按下某個鍵時,程序關閉,但是當您按任何鍵時,我希望它重新啓動... 我該怎麼做?我使用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循環http://www.cplusplus.com/doc/tutorial/control/ – CoryKramer
您需要閱讀一本書。 – Shoe
我看到人們並沒有抓住低掛的水果;) – CoryKramer