清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
C++自定义函数生成不重复的随机数
vector<int> getRandom(int total) { srand((int)time(NULL)); std::vector<int> input = *new std::vector<int>(); for (int i = 0; i < total; i++) { input.push_back(i); } vector<int> output = *new vector<int>(); int end = total; for (int i = 0; i < total; i++) { vector<int>::iterator iter = input.begin(); int num = random()%end; iter = iter+num; output.push_back(*iter); input.erase(iter); end--; } return output; }