题解 | #替换空格#
替换空格
https://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68
c语言
char* replaceSpace(char* s ) { char str[5000] = {}; int j = 0; for(int i = 0; s[i] != '\0'; ++i) { if(s[i] == ' ') { str[j++] = '%'; str[j++] = '2'; str[j++] = '0'; } else { str[j++] = s[i]; } } str[j++] = '\0'; return str; }