class Solution {
public:
void replaceSpace(char *str,int length) {
int count = 0;
for(int i = 0;i < length;i++)
if(str[i]==' ') count++;
int len = length + count * 2;
for(int i = length - 1,j = len - 1; i > -1,j > -1;)
{
if(str[i]==' ')
{
str[j--]='0';
str[j--]='2';
str[j--]='%';
i--;
}
else
str[j--] = str[i--];
}
}
};
剑指offer 替换空格
