标签:
fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区分大小写)。为了使句子不缺少成分,统一换成 “fjxmlhx” 。
输入包括多行。
每行是一个字符串,长度不超过200。
一行的末尾与下一行的开头没有关系。
输出包含多行,为输入按照描述中变换的结果。
The Marshtomp has seen it all before.
marshTomp is beaten by fjxmlhx!
AmarshtompB
The fjxmlhx has seen it all before.
fjxmlhx is beaten by fjxmlhx!
AfjxmlhxB
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 char s[201]; 6 int main(){ 7 while(gets(s)){ 8 int len = strlen(s); 9 for(int i = 0; s[i] != ‘\0‘; i++){ 10 if((s[i] == ‘M‘ || s[i] == ‘m‘) && (s[i + 1] == ‘A‘ || s[i + 1] == ‘a‘) 11 && (s[i + 2] == ‘R‘ || s[i + 2] == ‘r‘) && (s[i + 3] == ‘S‘ || s[i + 3] == ‘s‘) 12 && (s[i + 4] == ‘H‘ || s[i + 4] == ‘h‘) && (s[i + 5] == ‘T‘ || s[i + 5] == ‘t‘) 13 && (s[i + 6] == ‘O‘ || s[i + 6] == ‘o‘) && (s[i + 7] == ‘M‘ || s[i + 7] == ‘m‘) 14 && (s[i + 8] == ‘P‘ || s[i + 8] == ‘p‘)){ 15 printf("fjxmlhx"); 16 i += 8; 17 } else { 18 //printf("%c", s[i]); 19 putchar(s[i]); 20 } 21 } 22 cout << endl; 23 } 24 return 0; 25 }
hihocoder 1082 然而沼跃鱼早就看穿了一切(字符串替换)
标签:
原文地址:http://www.cnblogs.com/qinduanyinghua/p/5808863.html