C++中的random_shuffle随机化函数

STL中的函数random_shuffle()用来对一个元素序列进行随机排列。简单应用CF1156 - B. Ugly Pairs。

#include 
using namespace std;

int main()
{
    char b[] = "abcde";
    char a[10];
    cout<<"char:"< str;
    str.push_back("hello");
    str.push_back("world");
    str.push_back("welcome");
    str.push_back("to");
    str.push_back("Beijing");
    cout << endl << "string:" << endl;
    for(int i = 0; i < 10; i++)
    {
        random_shuffle(str.begin(),str.end());
        for(int j = 0; j < str.size(); j++)
         cout << str[j] << " ";
        cout<

 

你可能感兴趣的:(【你不知道的函数】)