题解 | #迭代器遍历容器#
迭代器遍历容器
https://www.nowcoder.com/practice/0f7ab22e60ee4574a9d9c81412b26595
#include <bits/stdc++.h> // write your code here...... using namespace std; vector <int> v; int main() { int x; for(int i=0;i<5;i++){ cin>>x; v.push_back(x); } // write your code here...... for(vector<int>::iterator i = v.begin();i!=v.end();i++){ cout<<*i<<" "; } puts(""); for(vector<int>::iterator i = v.end()-1;i!=v.begin()-1;i--){ cout<<*i<<" "; } puts(""); return 0; }