C++ 项不计算为带1个参数的函数错误?

C++ 项不计算为带1个参数的函数错误?,c++,algorithm,function,random,shuffle,C++,Algorithm,Function,Random,Shuffle,我写这段代码基本上是为了洗牌一个向量,我得到了这个错误,我不确定出了什么问题。我已经包括了算法。谢谢大家! // Shuffle the vector random_shuffle(names.begin(), names.end(), rand()); // Prelims cout << "ROUND PRELIMINATION: BEGIN" << endl; cout << names[32] << " versus " <<

我写这段代码基本上是为了洗牌一个向量,我得到了这个错误,我不确定出了什么问题。我已经包括了算法。谢谢大家!

// Shuffle the vector
random_shuffle(names.begin(), names.end(), rand());

// Prelims
cout << "ROUND PRELIMINATION: BEGIN" << endl;
cout << names[32] << " versus " << names[29] << endl << "Please enter the winner: ";
cin >> winner;
round1.push_back(winner);
cout << endl << names[33] << " versus " << names[30] << endl << "Please enter the winner: ";
cin >> winner;
round1.push_back(winner);
cout << endl << names[34] << " versus " << names[31] << endl << "Please enter the winner: ";
cin >> winner;
round1.push_back(winner);
for (int i = 0; i < 29; i++) {
    round1.push_back(names[i]);
}
//洗牌向量
随机洗牌(names.begin(),names.end(),rand());
//预备课程

coutrandom\u shuffle
的最后一个参数必须是返回随机选择值的函数对象
rand()
计算结果为
int
。因此,它不能用作函数的最后一个参数

以下几点应该行得通

// Shuffle the vector
random_shuffle(names.begin(), names.end(), [](int n) { return rand()%n; });

random\u shuffle
的最后一个参数必须是返回随机选择值的函数对象
rand()
计算结果为
int
。因此,它不能用作函数的最后一个参数

以下几点应该行得通

// Shuffle the vector
random_shuffle(names.begin(), names.end(), [](int n) { return rand()%n; });