Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
翻译:将给定字符串进行翻转,后输出翻转后的字符串。
例如:hello 变成olleh
class Solution{
public:
void swap(char &a,char &b)
{
char temp=a;
a=b;
b=temp;
}
string reverseString(string s)
{
int len=s.size();
int i=0;
int j=len-1;
while(i<j)
{
swap(s[i],s[j]);
i++;
j--;
}
return s;
}
};