版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sugarbliss/article/details/85077674
使用algorithm中的reverse函数
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s= "hello";
reverse(s.begin(),s.end());
cout<<s<<endl;
return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
char s[]= "hello";
reverse(s,s+5);
cout<<s<<endl;
return 0;
}