我是C ++的新手。
我需要将一个向量以相反的顺序复制到另一个向量。
这是我的做法:
int temp[] = {3, 12, 17};
vector<int>v(temp, temp+3);
vector<int>n_v;
n_v=v;
reverse(n_v.begin(), n_v.end()); //Reversing new vector
有没有简单的方法可以将向量以相反的顺序复制到STL中的另一个向量?
只需执行以下操作:
vector<int>n_v (v.rbegin(), v.rend());
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句