方法一
简洁代码,用库函数和STL
class Solution {
public:
void replaceSpace(char *str,int length) {
string solve;
for(int i=0; i<length; ++i)
{
if( ' '==str[i])
{
solve+="%20";
}
else
{
solve+=str[i];
}
}
strcpy( str, solve.c_str());
}
}; 方法二
倒着遍历,倒着放入,但是在之前要先扫描出几个空格,好多开几个大小的几倍

京公网安备 11010502036488号