C 随机数产生
// ConsoleApplication5.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <algorithm> #include <vector> #include <time.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { srand(unsigned(time(NULL)));//一定要这条,不然后面的结果每次运行都一样 std::vector<char> vv; vv.push_back('1'); vv.push_back('2'); vv.push_back('3'); vv.push_back('4'); vv.push_back('5'); vv.push_back('6'); printf("before random_shuffle:\n"); for(unsigned int i = 0; i < vv.size(); i++) { printf("vv is %c\n",vv.at(i)); } random_shuffle(vv.begin(),vv.end()); //需包含头文件#include <algorithm> printf("after random_shuffle:\n"); for(unsigned int i = 0; i < vv.size(); i++) { printf("vv is %c\n",vv.at(i)); } return 0; }