题意:

      给你一个串,如果出现子串 “Apple”, “iPhone”, “iPod”, “iPad“输出MAI MAI MAI!,如果出现子串Sony 输出SONY DAFA IS GOOD!.


思路:

     水题,直接模拟就行了,题目是一组测试数据,说是输入的小于8KB,这个我没有算具体要开多大,为了省事,我直接没开数字,用%c直接累加模拟就行了,有个地方注意下'\n'不能忽略,也就是说Appl\ne != Apple.


#include<stdio.h>

int main ()
{
int
s1 ,s2 ,s3 ,s4 ,s5;
char
c;
while(~
scanf("%c" ,&c))
{
if(
c == 'A') s1 = 1;
else if(
c == 'p' && s1 == 1) s1 = 2;
else if(
c == 'p' && s1 == 2) s1 = 3;
else if(
c == 'l' && s1 == 3) s1 = 4;
else if(
c == 'e' && s1 == 4)
{

printf("MAI MAI MAI!\n");
continue;
}else
s1 = 0; if(c == 'i') s2 = 1;
else if(
c == 'P' && s2 == 1) s2 = 2;
else if(
c == 'h' && s2 == 2) s2 = 3;
else if(
c == 'o' && s2 == 3) s2 = 4;
else if(
c == 'n' && s2 == 4) s2 = 5;
else if(
c == 'e' && s2 == 5)
{

printf("MAI MAI MAI!\n");
continue;
}else
s2 = 0; if(c == 'i') s3 = 1;
else if(
c == 'P' && s3 == 1) s3 = 2;
else if(
c == 'o' && s3 == 2) s3 = 3;
else if(
c == 'd' && s3 == 3)
{

printf("MAI MAI MAI!\n");
continue;
}else
s3 = 0; if(c == 'i') s4 = 1;
else if(
c == 'P' && s4 == 1) s4 = 2;
else if(
c == 'a' && s4 == 2) s4 = 3;
else if(
c == 'd' && s4 == 3)
{

printf("MAI MAI MAI!\n");
continue;
}else
s4 = 0; if(c == 'S') s5 = 1;
else if(
c == 'o' && s5 == 1) s5 = 2;
else if(
c == 'n' && s5 == 2) s5 = 3;
else if(
c == 'y' && s5 == 3)
{

printf("SONY DAFA IS GOOD!\n");
continue;
}else
s5 = 0; }
return
0;
}

最新文章

  1. DIV实现CSS 的placeholder效果
  2. char a[] = &quot;hello&quot;; char c[] = {&#39;h&#39;,&#39;e&#39;,&#39;l&#39;,&#39;l&#39;,&#39;o&#39;}; int b[] = {1, 2, 3, 4, 5};的长度区别,及内存中空间开辟情况
  3. UVa 10763 (STL) Foreign Exchange
  4. 多表关联查询(ORACLE版)
  5. Android应用盈利广告平台的嵌入方法详解
  6. POJ 1716 Integer Intervals#贪心
  7. Oracle where 0=1 or 1=1
  8. 难以理解的AQS(下)
  9. zepto.js-定制zepto步骤
  10. 简单了解request与response
  11. mysql学习(一)
  12. “Error:(1, 1) java: 非法字符: &#39;\ufeff&#39;”错误解决办法
  13. go语言,golang学习笔记4 用beego跑一个web应用
  14. UIUseImgWindow
  15. CentOS 6.7 安装配置 nagios
  16. linux中断申请之request_threaded_irq 【转】
  17. ansible的几点记录
  18. JavaScript编写简单的增加与减少元素
  19. 20155335俞昆《Java程序设计》第五周总结
  20. HTTP协议(一):介绍

热门文章

  1. 通达OA 越权访问-2013/2015版本
  2. FreeBSD ports 多线程编译
  3. js输入框只能输入数字
  4. AES加密--适用于RC2、RC4和Blowfish
  5. weex参考文章
  6. python网络编程--TCP客户端的开发
  7. c语言链表从本地文件中读取和写入数据
  8. 【LeetCode】2020-04 每日一题
  9. LinkedList类详解
  10. go每日一库 [home-dir] 获取用户主目录