vector-end


//      2018/04/16 9:46:45
//      vector-end

#include <iostream>
#include <vector>
#include <iterator>
#include <numeric>

using namespace std;

int main(){
    vector<int> v(5);
    iota(v.begin(),v.end(), 1);

    vector<int>::iterator it = v.begin();
    while (it != v.end()){
        cout << *(it++) << " ";
    }
    cout << endl;

    // last element of the vector
    it = v.end() - 1;
    cout << *it << endl;
    return 0;
}

/*
OUTPUT:
    1 2 3 4 5
    5
*/ 
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页