题解 | 迭代器遍历容器
迭代器遍历容器
https://www.nowcoder.com/practice/0f7ab22e60ee4574a9d9c81412b26595
#include <iostream>
// write your code here......
#include <vector>
using namespace std;
int main() {
// write your code here......
vector<int> v;
v.resize(5);
for(int i=0;i<5;i++)
{
cin >> v[i];
}
for(auto it=v.begin();it!=v.end();it++)
{
cout <<*it<<' ';
}
cout<<endl;
for(auto itr=v.rbegin();itr!=v.rend();itr++)
{
cout <<*itr<<' ';
}
return 0;
}
