The Marshtomp has seen it all before

来源:互联网 发布:阿里云 outllok 编辑:程序博客网 时间:2024/06/08 09:10
fjxmlhx不喜欢网上的 marshtomps 。所以他决定把所有的 “marshtomp”(名字不区分大小写) 改为 “fjxmlhx;
Input

    输入包含多行,每行字符串不超过200的长度,一个单词不会一半出现在上一行,剩下的在下一行。直到文件结束(EOF)
Output

    输出 替换之后的字符串。
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


代码:

#include<stdio.h>#include<string.h>using namespace std;char s[230];int Is(char ch){  //判断字符类型(大写字母,小写字母,非字母)    if(ch>='a'&&ch<='z') return 1;    else if(ch>='A'&&ch<='Z') return 2;    return 0;}int Strcmp(int a){  //与"marshtomp"进行匹配    char op[10]="marshtomp";    int i=a,j=0;    for(j=0;j<10;i++,j++){        if(Is(s[i])==0) break;        else if(Is(s[i])==1&&s[i]!=op[j]) break;        else if(Is(s[i])==2&&s[i]-'A'+'a'!=op[j]) break;    }    if(j<9) return 0;    return 1;}int main(){    while(gets(s)!=NULL){ //gets()返回类型为指针        int len=strlen(s);        int i;        for(i=0;i<len;i++){            if(Strcmp(i)){                    printf("fjxmlhx");                    i+=8;            }            else{                printf("%c",s[i]);            }        }        printf("\n");    }return 0;}