zoukankan      html  css  js  c++  java
  • find用法

     1 // find example
     2 #include <iostream>     // std::cout
     3 #include <algorithm>    // std::find
     4 #include <vector>       // std::vector
     5 
     6 int main () {
     7   // using std::find with array and pointer:
     8   int myints[] = { 10, 20, 30, 40 };
     9   int * p;
    10 
    11   p = std::find (myints, myints+4, 30);
    12   if (p != myints+4)
    13     std::cout << "Element found in myints: " << *p << '
    ';
    14   else
    15     std::cout << "Element not found in myints
    ";
    16 
    17   // using std::find with vector and iterator:
    18   std::vector<int> myvector (myints,myints+4);
    19   std::vector<int>::iterator it;
    20 
    21   it = find (myvector.begin(), myvector.end(), 30);
    22   if (it != myvector.end())
    23     std::cout << "Element found in myvector: " << *it << '
    ';
    24   else
    25     std::cout << "Element not found in myvector
    ";
    26 
    27   return 0;
    28 }
  • 相关阅读:
    thread同步测试
    thread互斥测试
    实验二测试
    第六章学习笔记
    opensslAPI
    第五章学习笔记
    stat命令的实现-mysate(必做)
    团队作业(三)
    第四章学习笔记
    学习笔记9
  • 原文地址:https://www.cnblogs.com/knmxx/p/10980186.html
Copyright © 2011-2022 走看看