HDU5007 Post Robot
生活随笔
收集整理的這篇文章主要介紹了
HDU5007 Post Robot
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Post Robot
http://acm.hdu.edu.cn/showproblem.php?pid=5007
思路:按單詞接受,枚舉字符的子串然后判斷。
#include <iostream> #include <cstring> #include <cstdio> using namespace std; const char t[5][10] = {{"Apple"},{"iPhone"}, {"iPod"}, {"iPad"}, {"Sony"} }; const char s1[20] = { "MAI MAI MAI!"}, s2[20] = {"SONY DAFA IS GOOD!"}; int ok(char * s) {if(strcmp(s, t[0]) == 0 || strcmp(s, t[1]) == 0 || strcmp(s, t[2]) == 0 || strcmp(s, t[3]) == 0)return 1;if(strcmp(s, t[4]) == 0)return 2;return 0; } int main() {//freopen("in.txt", "r", stdin);char s[100], c[100];while(scanf("%s", s) != EOF){int i, j, k, str = strlen(s);if(str < 4) continue;for(i = 0; i < str - 3; i++){for(j = i + 3; j < str; j++) //bananaiPad{if((j-i) >= 6) continue;int m = 0;for(k = i; k <= j; k++){c[m++] = s[k];}c[m] = '\0';if(ok(c) == 1){printf("%s\n", s1);i = j + 1;}if(ok(c) == 2){printf("%s\n", s2);i = j + 1;}}}}return 0; }
轉載于:https://www.cnblogs.com/lzq1126/p/5596860.html
總結
以上是生活随笔為你收集整理的HDU5007 Post Robot的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 蝉与马诗相同和不同
- 下一篇: 事件响应的优先级、stopProgapa