我正在使用 C++,我有 2 个相互关联的 vector :
vector<double> val = {.3,.5,.2,.4};
vector<string> str = {'a','b','c','d'};
我想在 val 中搜索最大值,然后在相同位置从 str 返回字符串:
vector<double>::const_iterator it;
it = max_element(val.begin(), val.end());
那么,我如何在 str
中使用 it
来获取字母呢?
string lettter;
letter = str.at(it-> ????? );
谢谢!!!
最佳答案
关于C++搜索MAX的 vector ,并从第二个 vector 中获得相同的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14715932/