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 size = s.size();
int temp;
//The most important is: 注意NULL结尾的字符串
for(int i=0; i<size/2; i++){
temp = s[i];
s[i] = s[size-1-i];
s[size-1-i] = temp;
}
return s;
}
};