题解 | 编写函数实现字符串翻转(引用方式)
#include<bits/stdc++.h>
using namespace std;
// write your code here......
void fanzhuan(string& s){
int len = s.size();
//双指针
int left = 0;
int right = len - 1;
char temp = ' ';
while (left <= right) {
temp = s[left];
s[left] = s[right];
s[right] = temp;
left ++;
right --;
}
}
int main(){
string s;
getline(cin,s);
// write your code here......
fanzhuan(s);
cout<<s;
return 0;
}
