从一堆数中随机取出一些值的方法:
#include#include #include #include using namespace std;int random(int min,int max){ return rand() % (max -min + 1) + min;}int main(){ int len = 20; vector vect; for(int i = 10; i < len + 10; i++) vect.push_back(i); int array[15]; for(int i = 0; i < 15; i++) { int num = random(0,len - i -1); array[i] = vect[num]; vect[num] = vect[len -i -1]; } for(auto& i : array) cout< <