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