C++使用vector

#include <iostream>
#include <string>
#include <vector>

using namespace std;

void show(vector<int> v)
{
        for(auto v1 : v){
                cout << v1 << endl;
        }
}

void show2(vector<int> v)
{
        for(vector<int>::const_iterator v1 = v.cbegin(); v1 != v.cend(); v1++){
                cout << *v1 << endl;
        }
}

int main()
{
        vector<int> int_vec;
        for(int i = 0; i < 100; i++){
                int_vec.push_back(i);
        }

        show2(int_vec);

        //for(vector<int>::iterator t = int_vec.begin(); t != int_vec.end(); t++){
        //      cout << *t << endl;
        //}
        /*循环vector*/
        //for(auto v : int_vec){
        //      cout << v << endl;
        //}
}
原文地址:https://www.cnblogs.com/bai-jimmy/p/5929787.html