lundi 9 septembre 2019

Get max value from vector [duplicate]

This question already has an answer here:

Why my result is NaN ? How to get the maximum value from vector if it contains 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;
}

Aucun commentaire:

Enregistrer un commentaire