从向量获取最大值

时间:2019-09-09 14:10:35

标签: c++ c++11

为什么我的结果是NaN?如果向量包含NaN,如何从向量中获取最大值

int main()
{
   std::vector<float> l_column;
    l_column.push_back(stof("nan"));
    l_column.push_back(stof("nan"));
    l_column.push_back(stof("-1"));
    l_column.push_back(stof("nan"));
    l_column.push_back(stof("nan"));
    l_column.push_back(stof("nan"));
    l_column.push_back(stof("1"));
    l_column.push_back(stof("nan"));
    auto mymax = *std::max_element(l_column.begin(), l_column.end());
    std::cout << mymax << std::endl;
    return 0;
}

0 个答案:

没有答案