help me plz...
Code: Select all
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int sort_function( const void *a, const void *b);
void main()
{
char z[10005][50];
char ara[50], temp[50];
int n, i, j, k, l, cs=0, len, flag;
while(scanf("%d", &n)==1)
{
cs++;
if(cs!=1) printf("\n");
i = 0;
while(1)
{
scanf("%s", temp);
if(!strcmp(temp, "EndOfText")) break;
len = strlen(temp);
for(j=0, k=0; j < len; j++)
if(isalnum(temp[j]))
ara[k++] = tolower(temp[j]);
ara[k] = 0;
temp[j] = 0;
if(!k) continue;
strcpy(z[i], ara);
i++;
}
z[i][0] = 0;
k = i;
qsort((void *)z, k, sizeof(char)*50, sort_function);
flag = 0;
for(i=0; i<k; )
{
strcpy(temp, z[i]);
for(j=i, l=0; !strcmp(z[j], z[j+1]);j++, l++);
if(++l==n)
{
printf("%s\n", z[i]);
flag = 1;
}
i = ++j;
}
if(!flag) printf("There is no such word.\n");
}
}
int sort_function( const void *a, const void *b)
{
return( strcmp((char *)a,(char *)b) );
}