使用函数
C/C++字符串 s 反转的N种方法C字符串char: strrev(s)
C++字符串string: reverse(str.begin(),str.end())
https://www.cnblogs.com/bk76120/p/10556037.html
char 字符串反转:
# include<iostream>
using namespace std;
int main() {
char s[] = "abcde";
strrev(s);
cout << s << endl;
return 0;
}
string 字符串反转:
# include<iostream>
# include <algorithm>
using namespace std;
int main() {
string str("abcde");
reverse(str.begin(), str.end()); //使用algorithm中的reverse函数
cout << str.c_str() << endl;
return 0;
}