有了逆向迭代器,反转就方便多了
vector<int> a = {1,2,3,4,5};
vector<int> c;
c.insert(c.end(),a.rbegin(),a.rend());
cout<<c[0]<<c[1]<<c[2]<<c[3]<<c[4]<<endl;
输出:
54321
这里如果把最后一个a.rend()换成a.begin()是不行的,同理a.rbegin()也不能换成a,end();
有了逆向迭代器,反转就方便多了
vector<int> a = {1,2,3,4,5};
vector<int> c;
c.insert(c.end(),a.rbegin(),a.rend());
cout<<c[0]<<c[1]<<c[2]<<c[3]<<c[4]<<endl;
输出:
54321
这里如果把最后一个a.rend()换成a.begin()是不行的,同理a.rbegin()也不能换成a,end();