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;
    }
  • 相关阅读:
    B-树和B+树
    线程与内核对象的同步-2
    线程与内核对象的同步
    高级线程同步 临界区
    Levenshtein Distance (编辑距离) 算法详解
    平衡二叉树
    静态查找表
    C++中的容器类详解
    How do I list all tables/indices contained in an SQLite database
    SmartGit STUDY 2
  • 原文地址:https://www.cnblogs.com/qlky/p/5685547.html
Copyright © 2011-2022 走看看