UVA10679 I Love Strings!!字符串匹配

Posted 海岛Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA10679 I Love Strings!!字符串匹配相关的知识,希望对你有一定的参考价值。

Hmmmmmm… strings again 😃 Then it must be an easy task for you. Well . . . you are given with a string S of length not more than 100,000 (only ‘a’-‘z’ and ‘A’-‘Z’). Then follows q (q < 1000) queries where each query contains a string T of maximum length 1,000 (also contains only ‘a’-‘z’ and ‘A’-‘Z’). You have to determine whether or not T is a sub-string of S.
Input
First line contains an integer k (k < 10) telling the number of test cases to follow. Each test case begins with S. It is followed by q. After this line there are q lines each of which has a string T as defined before.
Output
For each query print ‘y’ if it is a sub-string of S or ‘n’ otherwise followed by a new line. See the sample output below.
Sample Input
2
abcdefghABCDEFGH
2
abc
abAB
xyz
1
xyz
Sample Output
y
n
y

问题链接UVA10679 I Love Strings!!
问题简述:(略)
问题分析:字符串匹配问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10679 I Love Strings!! */

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int k, n;
    string s, t;

    cin >> k;
    while (k--) {
        cin >> s >> n;
        while (n--) {
            cin >> t;
            puts(strstr(s.c_str(), t.c_str()) ? "y" : "n");
        }
    }

    return 0;
}

以上是关于UVA10679 I Love Strings!!字符串匹配的主要内容,如果未能解决你的问题,请参考以下文章

UVa10220:I Love Big Numbers !

UVA10294 Arif in Dhaka (First Love Part 2)

Arif in Dhaka (First Love Part 2) UVA - 10294(Polya定理)

L1-026 I Love GPLT (5分)

「UVA10298」 Power Strings(KMP

uva 1585