69,382
社区成员
发帖
与我相关
我的任务
分享
for(i=0; i<10; ++i)
{
num = rand() % 10;
}
#include <vector>
#include <iostream>
#include <algorithm>
#include <ctime>
using namespace std;
int VecRandom(int num)
{
return rand() % num;
}
int main()
{
srand ( unsigned ( time (NULL) ) );
int Array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
vector<int> Vec( Array, Array + _countof( Array ) );
random_shuffle( Vec.begin(), Vec.end(), VecRandom);
copy ( Vec.begin(), Vec.end(), ostream_iterator<int> (cout, "\n") );
return 0;
}