大家是不是通常使用<iostream>这个库文件呢?有时用到了其他代码动不动就来个【error】,非常麻烦对吧,今天告诉大家一个万能库,包含了c++大多数库,那就是<bits/stdc++.h>
例如说生成20个不同的100以内的
随机数,要用到<cstdlib>这个标准库,但用<bits/stdc++.h>这个库,只要这个库就足够了。
#include<bits/stdc++.h>
using namespace std;
int main()
{
srand(time(0));//设置随机数种子
for(int i=1;i<=20;i++) cout<<rand()%101<<' ';
return 0;
}
就像上面这样,就一个错误也不会弹。
就像上面这样,正常运行。
(完)