#include <stdio.h>
void replaceSpace(char *str,int length)
{
int i=0,j=0;
while(i<length-1)
{
if(str[i]==' ')
{
j++;
}
i++;
}
j=length+j*2-1;
i=length-1;
while(i>=0)
{
if(str[i]==' ')
{
str[j--]='0';
str[j--]='2';
str[j--]='%';
}
else
{
str[j--]=str[i];
}
i--;
}
}
int main()
{
char str[11]="hello world";
replaceSpace(str,11);
return 0;
}
剑指offer 空格替换
最新推荐文章于 2020-02-02 20:52:31 发布