第一种:使用string.h中的strrev函数
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char s[]="hello";
strrev(s);
cout<<s<<endl;
return 0;
}
第二种:使用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;
}