hihoCoder - 1082 - 然而沼跃鱼早就看穿了一切 (字符串处理!!)
生活随笔
收集整理的這篇文章主要介紹了
hihoCoder - 1082 - 然而沼跃鱼早就看穿了一切 (字符串处理!!)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#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; }轉載于:https://www.cnblogs.com/yxwkf/p/5382210.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的hihoCoder - 1082 - 然而沼跃鱼早就看穿了一切 (字符串处理!!)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 远程ubuntu虚拟机Tensorflo
- 下一篇: MyBatis中的大于、小于、like等