Leetcode题目:Reverse String

题目:

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

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

解答:这个题目超级无敌简单,就是把一个string给逆过来输出。

代码:

class Solution {
public:
    string reverseString(string s) {
        stringstream res;
        res.clear();
        for(int i = s.length() - 1;i >= 0;i--)
        {
            res << s[i];
        }
        return res.str();
    }
};

原文地址:https://www.cnblogs.com/CodingGirl121/p/5421933.html