n个数里选出m个不重复的数
void change(int *p,int a,int b) { int tmp = *(p + a); *(p + a) = *(p + b); *(p + b) = tmp; } int main() { int a[100]; for (int i = 0 ;i < 101;++i) { a[i] = i + 100; } for (int i = 99;i >= 90;--i) { change(a,i,rand()%i); cout << a[i] <<endl; } return 0; }
一切源于对计算机的热爱