HDU5007 Post Robot
来源:互联网 发布:linux 命令下载文件 sz 编辑:程序博客网 时间:2024/06/06 00:27
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;}
0 0
- HDU5007 Post Robot
- HDU5007 Post Robot
- HDU5007-Post Robot
- hdu5007 Post Robot
- HDU5007 Post Robot(字符串处理)
- HDU5007-Post Robot-2014西安网络赛(字符串水题)
- HDU5007——Post Robot(2014 年 西安区域赛)
- Post Robot
- Post Robot(模拟)
- HDU - 5007 Post Robot
- HDOJ 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu5007 小水题
- hdu 5007 Post Robot 水题
- hdu 5007 Post Robot(水题)
- 关于死刑,何谓善?有感于电影《凝望深渊》
- 面试高频题
- Ubuntu下codeblocks的气泡球程序(四)
- C# 构子的实现
- HDU5007 Post Robot
- HDU5007 Post Robot
- 2015百度校园招聘机器学习/数据挖掘工程师笔试题(笔试时间:2014-9-14,哈尔滨站)
- ubuntu10.04的学习小结
- 异常处理
- Q&A about the _method_ meaning?
- 面向对象程序设计上机练习七(类和对象)
- 电面小记
- Redis源码学习-AOF
- C#操作字符串总结