#include<vector> #include<iostream> using namespace std; void main() { vector<int> vInt; vInt.push_back(1); vInt.push_back(2); vInt.push_back(3); vInt.push_back(4); vInt.push_back(5); vector<int>::iterator it=vInt.begin(); for (;it!=vInt.end();it++) { cout<<*it<<" "; } cout<<endl; vector<int>::reverse_iterator rit=vInt.rbegin(); for (;rit!=vInt.rend();rit++) { cout<<*rit<<" "; } cout<<endl; it=vInt.end(); for (--it;it!=vInt.begin();--it) { cout<<*it<<" "; } cout<<*it<<" "; cout<<endl; if (*(vInt.rbegin())==*(vInt.end()-1)) { cout<<"rbegin()== end()-1"<<endl; } else { cout<<"rbegin()!=end()"<<endl; } if (*(vInt.rend()-1)==*(vInt.begin())) { cout<<"rend()-1 ==begin()"<<endl; } else { cout<<"rend()!=begin()"<<endl; } } // 1 2 3 4 5 // 5 4 3 2 1 // 5 4 3 2 1 // rbegin()== end()-1 // rend()-1 ==begin() // Press any key to continue