Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
建立两个指针,一个在头一个在尾
交换两个指针的数值,之后一个++,一个--
class Solution {
public:
string reverseString(string s) {
int start=0;
int end=s.size()-1;
int swap;
while(start<=end)
{
swap=s[start];
s[start]=s[end];
s[end]=swap;
start=start+1;
end=end-1;
}
return s;
}
};