C/C++ code#include
#include
char s[256];
char *p;
int r,n,i;
int main() {
while (1) {
printf("请输入一行文字(空行结束),\"%%20\"将替换为\" \",\"你懂得\"将替换为\"XXXXXX\":\n");
fgets(s,256,stdin);
if ('\n'==s[0]) break;
p=s;
while (1) {
p=strstr(p,"%20");
if (p) {
memmove(p+1,p+3,strlen(p)-3+1);
p[0]=' ';
} else break;
}
p=s;
while (1) {
p=strstr(p,"你懂得");
if (p) {
memmove(p+6,p+6,strlen(p)-6+1);
for (i=0;i<6;i++) p[i]='X';
} else break;
}
printf("%s",s);
}
return 0;
}
//请输入一行文字(空行结束),"%20"将替换为" ","你懂得"将替换为"XXXXXX":
//abcdefg%20helloworld%20something.pdf
//abcdefg helloworld something.pdf
//请输入一行文字(空行结束),"%20"将替换为" ","你懂得"将替换为"XXXXXX":
//这是测试文字你懂得,在这个你懂的地方,就得做你懂得的事
//这是测试文字XXXXX,在这个你懂的地方,就得做XXXXX的事
//请输入一行文字(空行结束),"%20"将替换为" ","你懂得"将替换为"XXXXXX":
//