题解 | #迭代器遍历容器#
迭代器遍历容器
https://www.nowcoder.com/practice/0f7ab22e60ee4574a9d9c81412b26595
#include <algorithm> #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(vector<int>::iterator it=v.begin();it!=v.end();it++) { cout<<*it<<" "; } cout<<endl; reverse(v.begin(), v.end()); for(vector<int>::iterator it=v.begin();it!=v.end();it++) { cout<<*it<<" "; } return 0; }