题解 | #替换空格#
替换空格
https://www.nowcoder.com/practice/4060ac7e3e404ad1a894ef3e17650423
class Solution { public: void replaceSpace(char *str,int length) { int i=length-1; while (i-->=0) { if (str[i]==' ') { length+=2; for (int j=length-1; j>i; j--){ str[j]=str[j-2]; } str[i]='%'; str[i+1]='2'; str[i+2]='0'; } } } };