VWORDPOW - Sức mạnh của ngôn từ

Tác giả: hieult

Ngôn ngữ: C++

#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include <conio.h>

int main()
{
    //freopen("WWORDPOW.in","r",stdin);
    int n,m;
    char s[1001][1001],k[100001][31];
    int ls[1001],lk[100001],x,y;
    scanf("%d %d",&n,&m);
    for(int i = 1;i<=n;i++)
    {
        scanf("%s",s[i]);
        ls[i] = strlen(s[i]);
        for(int j = 0;j<ls[i];j++)
            s[i][j] = tolower(s[i][j]);
    }
    for(int i = 1;i<=m;i++)
    {
        scanf("%s",k[i]);
        lk[i] = strlen(k[i]);
        for(int j = 0;j<=lk[i];j++)
            k[i][j] = tolower(k[i][j]);
    }
    for(int i = 1;i<=n;i++)
    {
        int KQ = 0;
        for(int j = 1;j<=m;j++)
        {
            		x=0;
			for(y=0;s[i][y];y++)
			{
				if(s[i][y]==k[j][x])
					x++;
				if(!k[j][x]){
					KQ++;break;
				}
			}
        }
        printf("%d\n",KQ);
    }
   // getch();
}
        
    



Download