#include <stdio.h> #include <vector> #include <algorithm> //random_shuffle #include <time.h> int gen(int i) {return rand()%i; } int main() { srand(time(0)); std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); random_shuffle(v.begin(), v.end(), gen); for (unsigned int x=0; x<v.size(); x++) printf("%d\n", v[x]); return 0; }
沒有留言:
張貼留言