引入头文件<ctime>
运用函数 - random_shuffle and srand
输入n个人 和 需要的随机数数量
输出:随机数
详见代码
# include <iostream>
# include <vector>
# include <algorithm>
# include <cstdio>
# include <ctime>
using namespace std;
int main()
{
printf("Plase enter total number and random number");
srand(time(0));
int num, rans;
cin >> num >> rans;
int a[200];
for(int i = 1; i <= num; i ++) a[i] = i;
random_shuffle(a + 1 , a + num + 1);
for(int i = 1; i <= rans; i ++) cout << a[i] << ' ';
return 0;
}