Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个vector<int> v{1, 2, 3}
vector<int> v{1, 2, 3}
我有一个功能:int square(int x){return x*x;}
int square(int x){return x*x;}
我的问题是:我如何正确找到 的argmax(in v) square(v)?
argmax
v
square(v)
在这种情况下9大于4和1。因此结果应该给出3。
9
4
1
3
我可以使用索引,"square(v)"然后使用该索引来检索v. 但也许有一个 c++ 内置函数或更优雅的方式来进行?
"square(v)"