#include <iostream>
#include <string>
using namespace std;
int main ()
{
string s;
cin>>s;
cout<<"pre:"<<s<<endl;
s.assign(s.rbegin(),s.rend());//逆序开始位置迭代,逆序结束位置迭代
cout<<"post:"<<s<<endl;
return 0;
}
assign函数
1.函数声明
string& assign (InputIterator first, InputIterator last); //迭代类
2.函数功能
将后面str指定位置指定长度字符串赋值给前面