剑指OFFER----面试题05.替换空格

链接:https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/

 

代码:

class Solution {
public:
    string replaceSpace(string s) {
        string res;
        for (auto x: s) {
            if (x == ' ')
                res += "%20";
            else
                res += x;
        }
        return res;
    }
};

 

posted @ 2020-02-15 17:31  景云ⁿ  阅读(87)  评论(0编辑  收藏  举报