C ++ standard library std :: find Find

See: https: //en.cppreference.com/w/cpp/algorithm/find

 

Find the specified character / number and so on.

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
 
int main()
{
    int n1 = 3;
    int n2 = 5;
 
    std::vector<int> v{0, 1, 2, 3, 4};
 
    auto result1 = std::find(std::begin(v), std::end(v), n1);
 
    if (result1 == std::npos) {
        std::cout << "no found " << n1 << '\n';
    }

    return 0  
}

  

Guess you like

Origin www.cnblogs.com/alexYuin/p/11546198.html