for(;;) {
int rand_number = rand() % 2;
cout << rand_number;
}
Run Code Online (Sandbox Code Playgroud)
这些循环在屏幕上生成1和0,就像矩阵电影(LOL)一样,但代码执行得非常快,有没有什么方法可以使数字显得缓慢?
使用Sleep(3000);等待3000毫秒例如
#include <iostream>
#include <stdlib.h>
#include <Windows.h>
using namespace std;
int main(int argc,char**argv){
cout<<"a"<<endl;
Sleep(3000);
cout<<"b"<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)