
and can't find the bug.
someone help me plz...
here is my code:
[cpp]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_function( const void *a, const void *b)
{
return( strcmp((char *)a,(char *)b) );
}
void main()
{
char *ara[] = {"", "qaz", "wsx", "edc", "rfvtgb", " ", " ", "yhnujm", "ik,", "ol.", "p;/"};
char in[55];
char word[1001][55];
char ch;
int finger[11];
int n, p;
int i, j, k, l, m, max, len;
int flag, count;
while(2==scanf("%d%d", &p, &n))
{
for(i=1; i<11; i++) finger = 1;
for(i=0; i<p; i++)
{
scanf("%d", &j);
finger[j] = 0;
}
max = 0;
for(i=0; i<n; i++)
{
scanf("%s", in);
flag = 1;
len = strlen(in);
for(j=0; j<len && flag; j++)
{
ch = in[j];
for(k=1; k<=10 && flag; k++)
{
for(l=0; l<strlen(ara[k]); l++)
{
if(ch==ara[k][l])
{
if(!finger[k])
{
flag = 0;
break;
}
}
}
}
}
if(flag)
{
if(len > max)
{
m = 0;
strcpy(word[m++], in);
max = len;
}
else if(len==max)
strcpy(word[m++], in);
}
}
qsort((void *)word, m, sizeof(word[0]), sort_function);
for(i=0, count=0; i<m;)
{
j = i;
while(!strcmp(word, word[j]))
{
count++;
j++;
if(j==m) break;
}
i = j;
count--;
}
count = m - count;
printf("%d\n", count);
for(i=0; i<m; )
{
printf("%s\n", word);
j = i;
while(!strcmp(word, word[j]))
{
j++;
if(j==m) break;
}
i = j;
}
}
}
[/cpp]