剑指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;
    }
};

猜你喜欢

转载自www.cnblogs.com/clown9804/p/12312829.html