c++中字符串反转的3种⽅法
第⼀种:使⽤string.h中的strrev函数
#include #include using namespace std;int main(){char s[]=\"hello\"; strrev(s); cout<第⼆种:使⽤algorithm中的reverse函数
#include #include #include using namespace std;int main(){string s = \"hello\"; reverse(s.begin(),s.end()); cout<第三种:⾃⼰编写
#include using namespace std;void Reverse(char *s,int n){ for(int i=0,j=n-1;iint main(){char s[]=\"hello\"; Reverse(s,5); cout<