#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char c[100] = "we are happy";
int space_num = 2;
int pos = strlen(c);
int new_pos = pos + (2 * space_num);
while(pos >= 0)
{
if(c[pos] == ' ')
{
c[new_pos--] = '0';
c[new_pos--] = '2';
c[new_pos--] = '%';
pos--;
}
else
{
c[new_pos--] = c[pos--];
}
}
printf("%s\n", c);
return 0;
}
C++ 将“we are happy”中的空格替换成%20,即“we%20are%20happy”
最新推荐文章于 2021-10-17 11:09:50 发布