hihoCoder,hihocoderwa

來源:互聯網
上載者:User

hihoCoder,hihocoderwa

#1082 : 然而沼躍魚早就看穿了一切時間限制:1000ms單點時限:1000ms記憶體限制:256MB
描述


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

字串處理!!!


AC代碼:

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char a[210];int judge(char a[], int n){if(a[n+1] == 'A' || a[n+1] == 'a')if(a[n+2] == 'R' || a[n+2] == 'r')if(a[n+3] == 'S' || a[n+3] == 's')if(a[n+4] == 'H' || a[n+4] == 'h')if(a[n+5] == 'T' || a[n+5] == 't')if(a[n+6] == 'O' || a[n+6] == 'o')if(a[n+7] == 'M' || a[n+7] == 'm')if(a[n+8] == 'P' || a[n+8] == 'p')return 1;return 0;}void fun(char a[], int n){int len = strlen(a);a[n] = 'f'; a[n+1] = 'j';a[n+2] = 'x'; a[n+3] = 'm';a[n+4] = 'l'; a[n+5] = 'h';a[n+6] = 'x';for(int i=n+7; i<len-2; i++){a[i] = a[i+2];}a[len-2] = '\0';}int main(){while(gets(a)!=NULL){int len =strlen(a);for(int i=0; i<len-8; i++){if(a[i] == 'M' || a[i] == 'm'){if(judge(a, i)){fun(a, i);}}}printf("%s\n", a);}return 0;}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.