强行用c++写

替换空格

http://www.nowcoder.com/questionTerminal/4060ac7e3e404ad1a894ef3e17650423

class Solution {
public:
    void replaceSpace(char *str,int length) {
        string s(str);
       string res;
        for(auto &x:s){
            if(x==' ')
                res+="%20";
            else
                res+=x;
        }
        auto ret=res.c_str();
        strcpy(str,ret);
    }
};
全部评论
👍
点赞 回复 分享
发布于 2020-01-15 12:33

相关推荐

10-16 15:48
算法工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务