题解 | #替换空格#
替换空格
https://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68
class Solution {
public:
string replaceSpace(string s) {
string new_str = "";
for (auto& str : s) {
if (str == ' ') {
new_str += "%20";
}
else new_str += str;
}
return new_str;
}
};
public:
string replaceSpace(string s) {
string new_str = "";
for (auto& str : s) {
if (str == ' ') {
new_str += "%20";
}
else new_str += str;
}
return new_str;
}
};