344

编写一个函数,其作用是将输入的字符串反转过来。

class Solution {
public:
    string reverseString(string s) {
        int len = s.size();
        string result;
        for(int n = 0; n < len; n++)
        {
            result.append(1,s.at(len - 1 - n));
        }
        return result;
    }
};

 

posted @ 2018-09-25 21:30  Qian_Lu  阅读(300)  评论(0)    收藏  举报