gpt4 book ai didi

c++ - 错误 : No Match Function to Call

转载 作者:太空宇宙 更新时间:2023-11-03 10:29:35 27 4
gpt4 key购买 nike

我想让我的 vector vector_list 没有任何重复数据。这里的代码:

int is_Tally(int num ) 
{
vector<int> vector_list;
for(int i=1; i< 1000;i++)
{
int item = (i*num)%10000;
if (vector_list.empty())
{
vector_list.push_back(item);
}
else
{
if (find(vector_list.begin(), vector_list.end(), item)!=vector_list.end())
{
vector_list.push_back(item);
if (vector_list.size()>15)
{
return 0;
}
}
}
}
return vector_list.size();

当我执行代码时出现错误。

error: no matching function for call to 'find(__gnu_cxx::__normal_iterator<int*,     std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int&)

有什么建议吗?谢谢。

最佳答案

标准库函数 find 在命名空间 std 中.

std::find .

也不要忘记 #include <algorithm> .

关于c++ - 错误 : No Match Function to Call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20876800/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com