int a = max_element(highesthuman[0], highesthuman[2]);
if( win > loss)
{
cout << "You won " << (win-loss) << " games more than the computer did! You used " << a << " the most.";
}
}
上面的数组由下式给出
int humanrock = 0;
int humanpaper = 0;
int humanscissors = 0;
int highesthuman [3] = {humanrock, humanpaper, humanscissors};
当运行我的整个程序时,我收到一条错误消息“一元类型参数无效”。我查了一下,但无法理解“指针”或人们所指的内容。
std::max_element() http://www.cplusplus.com/reference/algorithm/max_element/接受两个迭代器作为参数,并返回一个迭代器。在你的情况下,迭代器是指针。所以你应该改变
int a = max_element(highesthuman[0], highesthuman[2]);
to
int a = *max_element(highesthuman, highesthuman + 3);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)