数组

1108.IP 地址无效化
题目链接:https://leetcode.cn/problems/defanging-an-ip-address/description/
题解代码:

class Solution {
public:
    string defangIPaddr(string address) {
        string ans;
        for(auto&c:address)
        {
            if(c == '.') ans+="[.]";
            else ans+=c;
        }
        return ans;
    }
};
posted @ 2024-11-20 01:37  fufuaifufu  阅读(1)  评论(0编辑  收藏  举报