zoukankan      html  css  js  c++  java
  • C++类属性算法find

    类属性算法find分别用于数组、表和输入迭代器

    1 #include <iostream>
    2 #include <cassert>
    3 #include <algorithm>
    4 #include <list>
    5 #include <iterator>
    6
    7  using namespace std;
    8
    9  int main()
    10 {
    11 int a[10]={12,3,25,7,11,213,7,123,29,-31};
    12 //int *ptr=find(&a[0],&a[10],7);
    13 //assert (*ptr==7 && *(ptr+1)==11);
    14 list<int> list1(&a[0],&a[10]);
    15 list<int>::iterator i=find(list1.begin(),list1.end(),7);
    16 assert (*i==7 && *(++i)==11);
    17
    18 cout<<"Type some characters,including an 'x' followed\n"<<"by at least one nonwhite-space character: "<<flush;
    19 istream_iterator<char> in(cin);
    20 istream_iterator<char> eos;
    21 find(in,eos,'x');
    22 cout<<"The first nonwhite-space character following\n"<<"the first 'x' was '"<<*(++in)<<"'."<<endl;
    23
    24 return 0;
    25 }
  • 相关阅读:
    Android开发系列之ListView用法
    自省
    fake feeling ?
    我心中的天使
    2020.6.16
    python面试题
    tcp
    Short + skip + limit
    01_pyttsx3_将文本文字转为语音播放
    mongo_Linux下不进入数据库查数据
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2057380.html
Copyright © 2011-2022 走看看