#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
//reverse(iterator begin,iterator end)
void myPrint(int val)
{
cout << val << " ";
}
void test1201()
{
vector<int> v;
for (int i = 0; i < 10; i++)
{
v.push_back(i);
}
cout << "翻转前:" << endl;
for_each(v.begin(), v.end(), myPrint);
cout << endl;
cout << "翻转后:" << endl;
reverse(v.begin(), v.end());
for_each(v.begin(), v.end(), myPrint);
}
int main()
{
test1201();
system("pause");
return 0;
}
网友评论