zoukankan      html  css  js  c++  java
  • HDU 5007 字符串匹配

    http://acm.hust.edu.cn/vjudge/contest/122814#problem/A

    匹配到字符串就输出,水题,主要是substr的运用

    #include <iostream>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <cmath>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <cctype>
    #include <vector>
    #include <iterator>
    #include <set>
    #include <map>
    #include <sstream>
    using namespace std;
    
    #define mem(a,b) memset(a,b,sizeof(a))
    #define pf printf
    #define sf scanf
    #define spf sprintf
    #define pb push_back
    #define debug printf("!
    ")
    #define MAXN 205
    #define MAX(a,b) a>b?a:b
    #define blank pf("
    ")
    #define LL long long
    #define ALL(x) x.begin(),x.end()
    #define INS(x) inserter(x,x.begin())
    #define pqueue priority_queue
    #define INF 0x3f3f3f3f
    
    int n,m;
    
    int main()
    {
        int i,j;
        string str;
        while(cin>>str)
        {
            int len = str.size();
            for(i=0;i<len;i++)
            {
                if(len-i>=4)
                {
                    string tmp = str.substr(i,4);
                    if(tmp == "iPad" || tmp == "iPod") pf("MAI MAI MAI!
    ");
                    else if(tmp == "Sony") pf("SONY DAFA IS GOOD!
    ");
                }
                if(len-i>=5)
                {
                    string tmp = str.substr(i,5);
                    if(tmp == "Apple") pf("MAI MAI MAI!
    ");
                }
                if(len-i>=6)
                {
                    string tmp = str.substr(i,6);
                    if(tmp == "iPhone") pf("MAI MAI MAI!
    ");
                }
            }
    
        }
        return 0;
    }
  • 相关阅读:
    BeyondLinux_Since1991
    TED系列:我们究竟在教AI学习什么
    TED系列:算法的影响
    TED系列:代码-下一代的通用语言
    TED系列:互联网源起故事
    Hadoop-01 搭建hadoop伪分布式运行环境
    JavaSE-26 Swing
    JavaSE-25 AWT
    JavaSE-24 多线程
    JavaSE-23 注解
  • 原文地址:https://www.cnblogs.com/qlky/p/5685547.html
Copyright © 2011-2022 走看看