1073: 动物简介(animal)

#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include <math.h>

using namespace std;

int m;
char a[250];
char b[250];
int c;
int main(){
    scanf("%d %s",&m,a);
    //printf("%s
",b);
    //cin>>m;
    //cin>>a;
    gets(b);
    int lena = strlen(a);
    c = 0;
    for(int i = 0 ; i< m; i++)
    {
        gets(b);
        int lenb = strlen(b);
        for(int j= 0;j <= lenb-lena ; j++)
        {
            bool f = true;
            for(int k= 0;k < lena ; k++)
            {
                if(b[j+k] != a[k])
                {
                    f = false;
                    break;
                }
            }
            if(f)
            {
                c++;
            }
        }
    }
    cout<<c<<endl;
    //printf("%0.4f
",s);
    //printf("%s
",a);
    return 0;
}
原文地址:https://www.cnblogs.com/shiningrise/p/6649998.html