头文件
#include <algorithm>
翻转数组
int a[] = {1,2,3 ,4,5,6,7};
reverse(&a[0],&a[2]);
翻转容器
vector<int> v = {5,4,3,2,1};
reverse(v.begin(),v.end());
//对[begin, end]进行翻转,v的值为1,2,3,4,5
vector<int> v = {5,4,3,2,1};
reverse(v.begin()+1,v.end()-1);
//对[begin+1, end-1]进行翻转,v的值为5,2,3,4,1
翻转 string
string str="www.mathor.top";
reverse(str.begin(),str.end());
str变为"pot.rohtam.wwww"