哪個命令讓我通過提示輸入來關閉我的新隨機數字?我試圖寫系統(「暫停」),但隨後出現「按任意鍵繼續」,我不喜歡。有沒有可能只需按下輸入按鈕並一個接一個看數字?如何在按回車後使用cout打印文本?
下面是程序代碼:
#include <iostream>
using namespace std;
#include <stdlib.h>
#include <ctime>
int main()
{
int i, k;
srand(time(0));
for (i = 0; i < 20; i++)
{
cout << (rand() % 8) << endl;
}
}
這是功課,對吧? :-) –
嘗試cin.readline(),或者如果你不需要聽取具體的輸入然後cin.readchar()。 –
nope :)真的,我不知道該怎麼做.. –