View Code of Problem 97

#include "stdio.h"
#include "math.h"
#include "string.h"



void main()
{
	int n;
	char s[2000][100];
	char a[2000][100];
	char b[100];
	int i,j,k;
	for(;scanf("%d",&n)!=EOF;)
	{
		if(n==0)
			break;
		for(i=0;i<n;i++)
			scanf("%s",s[i]);
		for(i=0,k=0;i<n;i++)
		{
			for(j=0;j<=strlen(s[i])-5;j++)
			{
				b[j]=s[i][j];			
			}
			b[j]='\0';
			for(j=0;j<n;j++)
			{
				if(strcmp(b,s[j])==0)
				{

					strcpy(a[k],b);	
				//	puts(a[k]);
					k++;
				//	printf("%d\n",k);
				}
			}
		}
		
		for(i=0;i<k;i++)
		{
			for(j=0;j<k-i-1;j++)
			{	
				if(strcmp(a[j],a[j+1])==1)
				{
					strcpy(b,a[j]);strcpy(a[j],a[j+1]);strcpy(a[j+1],b);
				}
			}
		}
		for(i=0;i<k;i++)
		{
			printf("%s.exe\n",a[i]);
		}

	}
}

Double click to view unformatted code.


Back to problem 97