JZ5 替换空格
题目链接
替换空格_牛客题霸_牛客网 (nowcoder.com)
完整代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include <string> class Solution { public:
string replaceSpace(string s) { string str2 ="%20"; string str3; for (int i=0; i<s.size(); i++) { if(s[i]!=' ') str3.push_back(s[i]); else str3.append(str2); } return str3; } };
|