65,186
社区成员




#include <iostream>
#include <string>
using namespace std;
int main()
{
char *str = "We Are Happy";
int i = 0, j, length = 12;
while (str[i] != '\0')
{
if (str[i] == ' ')
{
length += 2;
for (j = length - 3; j > i; j--)
str[j + 2] = str[j];
str[i] = '%';
str[i + 1] = '2';
str[i + 2] = '0';
}
++i;
}
cout << str << endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str[] = "We Are Happy";
int i = 0, j, length = 12;
while (str[i] != '\0')
{
if (str[i] == ' ')
{
length += 2;
for (j = length - 3; j > i; j--)
{
str[j + 2] = str[j];
str[j + 3] = '\0';
}
str[i] = '%';
str[i + 1] = '2';
str[i + 2] = '0';
}
++i;
}
cout << str << endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str[] = "We Are Happy";
int i = 0, j, length = 12;
while (str[i] != '\0')
{
if (str[i] == ' ')
{
length += 2;
for (j = length - 3; j > i; j--)
{
str[j + 2] = str[j];
str[j + 3] = '\0';
}
str[i] = '%';
str[i + 1] = '2';
str[i + 2] = '0';
}
++i;
}
cout << str << endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str[] = "We Are Happy";
int i = 0, j, length = 12;
while (str[i] != '\0')
{
if (str[i] == ' ')
{
length += 2;
for (j = length - 3; j > i; j--)
{
str[j + 2] = str[j];
str[j + 3] = '\0';
}
str[i] = '%';
str[i + 1] = '2';
str[i + 2] = '0';
}
++i;
}
cout << str << endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
char *str = "We Are Happy";
string strdst;
int i = 0, length = 12;
while (str[i] != '\0')
{
if (str[i] == ' '){
strdst+="%20";
}
else{
strdst += str[i];
}
++i;
}
cout << strdst << endl;
system("pause");
return 0;
}
#include <stdio.h>
#include <string.h>
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":
//