zoukankan      html  css  js  c++  java
  • list-begin

    ////////////////////////////////////////
    //      2018/04/25 21:12:41
    //      list-begin
    
    // return an iterator to the beginning
    #include <iostream>
    #include <list>
    #include <algorithm>
    #include <iterator>
    #include <numeric>
    
    using namespace std;
    
    int main(){
        list<int> l(5);
        iota(l.begin(), l.end(), 1);
    
        list<int>::iterator it = l.begin();
        while (it != l.end()){
            cout << *(it++) << " ";
        }
        cout << endl;
    
        // third element of the list
        it = l.begin();
        it++;
        it++;
        cout << *it << endl;
    
        return  0;
    }
    
    /*
    OUTPUT:
        1 2 3 4 5
        3
    */ 
  • 相关阅读:
    总结
    总结
    总结
    总结
    合作成功案例
    本周作业
    上周作业
    本周总结
    本周作业
    分答
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537973.html
Copyright © 2011-2022 走看看