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 k=(int)s.length();
int i;
char a;
for(i=0;i<(k+1)/2;i++){
a=s[k-i-1];
s[k-i-1]=s[i];
s[i]=a;
}
return s;
}
};