Computer Scientists are Pretty Pessimistic

Tuesday, 1 March 2016

Use of Iterator in C++

#include <iostream>
#include <vector>
#include <iterator>
#include <cstdio>
using namespace std;
int main()
{
    vector<int>v;
    vector<int>::iterator j;
    int i,val;
    for(i=0;i<10;i++)
    {
        cin>>val;
        v.push_back(val);
    }
    for(j=v.begin();j<v.end();j++)
    {
        cout<<*j<<endl;
    }
    return 0;
}

No comments:

Post a Comment