This is a matter of character processing;
1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <math.h>5 6 inta[211];7 voidFind (Char*ch1,Char*CH3);8 9 intMain ()Ten { One intI, L1, K; A Charch[ About], ch1[ About]; - Charch3[]= {"Marshtomp"}; - while(Gets (ch)! =NULL) the { -L1 =strlen (CH); -K =0; - for(i =0; i<l1; i++) + { - if(ch[i]>='A'&& ch[i]<='Z') +Ch1[i] = ch[i]+ +; A Else atCh1[i] =Ch[i]; - } - Find (CH1, CH3); - for(i =0; i<l1; i++) - { - if(i = =A[k]) in { -printf"FJXMLHX"); toi+=8; +k++; - } the Else *printf"%c", Ch[i]); $ }Panax Notoginsengprintf"\ n"); - } the return 0; + } A voidFind (Char*ch1,Char*CH3) the { + intI, J, Len, L1; - intK; $Len = strlen (CH1)-strlen (CH3); $L1 =strlen (CH3); -K =0; -Memset (A,-1,sizeof(a)); the for(i =0; i<len; i++) - {Wuyi if(Ch1[i] = = ch3[0]) the { - for(j =1; j<l1; J + +) Wu { - if(Ch1[i+j]! =Ch3[j]) About Break; $ } - if(J = =L1) - { -A[K] =i; Ak++; + } thej =0; - } $ } the}
Code as above;
| Description |
FJXMLHX is being brushed by a swamp fish every day, so he's eagerly finding you. You want to write a program that masks all the sentences in the Marsh Jump Fish ("marshtomp", not case sensitive). In order to make the sentence not lack of ingredients, unified replaced by "FJXMLHX". |
| Input |
The input includes multiple lines. Each line is a string with a length of not more than 200. The end of a line has no relation to the beginning of the next line. |
| Output |
| The output contains multiple lines, as the input follows the result of the transformation in the description. |
| Sample Input |
The Marshtomp has seen it all before. Marshtomp is beaten by fjxmlhx! Amarshtompb |
| Sample Output |
The FJXMLHX has seen it all before. Fjxmlhx is beaten by fjxmlhx! Afjxmlhxb |
| Hint |
There is no Mar Shto MP that is separated by a space. It is possible that there are more than two "marshtomp" in a sentence. |
| Source |
| The fifth annual ACM Program Design Contest of Harbin Polytechnic University |
Character Processing Marsh jump fish