Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh".

代码如下:

方法一:(java)

1 public class Solution {
2     public String reverseString(String s) {
3 
4         StringBuffer t=new StringBuffer(s);
5         return t.reverse().toString();
6     }
7 }

 方法二:(c++)

1 class Solution {
2 public:
3     string reverseString(string s) {
4         reverse(s.begin(),s.end());
5         return s;
6     }
7 };