c++ 容器反转并且拷贝到一个新容器中

时间:2023-03-08 23:39:46
c++ 容器反转并且拷贝到一个新容器中
// reverse_copy example
#include <iostream> // cout
#include <algorithm> // reverse_copy
#include <vector> // vector
using namespace std;
int main () {
int myints[] ={,,,,,,,,};
vector<int> myvector; myvector.resize(); // allocate space reverse_copy (myints, myints+, myvector.begin()); // print out content:
cout << "myvector contains:";
for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
cout << ' ' << *it; cout << '\n'; return ;
}