• hdu5007 小水题


    题意:

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


    思路:

         水题,直接模拟就行了,题目是一组测试数据,说是输入的小于8KB,这个我没有算具体要开多大,为了省事,我直接没开数字,用%c直接累加模拟就行了,有个地方注意下' '不能忽略,也就是说Appl e != 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!
    ");
             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!
    ");
             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!
    ");
             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!
    ");
             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!
    ");
             continue;
          }else s5 = 0;
         
       }
       return 0;
    }
          
    

  • 相关阅读:
    MySQL临时表
    git开发常用命令
    PHP资源列表
    Golang学习--平滑重启
    Golang学习--TOML配置处理
    Golang学习--包管理工具glide
    Golang学习--开篇
    构建自己的PHP框架--构建模版引擎(3)
    构建自己的PHP框架--构建模版引擎(2)
    Laravel Session 遇到的坑
  • 原文地址:https://www.cnblogs.com/csnd/p/12062787.html
Copyright © 2020-2023  润新知