View Code of Problem 97

#include<stdio.h>
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF&&n!=0){
		char a[n][100];
		char b[n][100];
		char temp[100];
		int i,j;
		for(i = 0;i < n; i++){
			scanf("%s",a[i]);
		}
		int count = 0;
		for(i = 0;i < n; i++){
			int len =strlen(a[i]);
			if(a[i][len-1]=='e'&&a[i][len-2]=='x'&&a[i][len-3]=='e'&&a[i][len-4]=='.'){
				strcpy(temp,a[i]);
				temp[len-4] = '\0';
				for(j = 0;j < n; j++){
					if(strcmp(temp,a[j])==0){
						strcpy(b[count++],a[i]);
						break;
					}
				}
			}
		}
		 for(i=0;i<count-1;i++){        //冒泡 
            for(j=count-1;j>i;j--){
                if(strcmp(b[j-1],b[j])>0)
                {
                    strcpy(temp,b[j-1]);
                    strcpy(b[j-1],b[j]);
                    strcpy(b[j],temp);
                }
            }
        }
		for(i = 0;i < count ; i++){
			printf("%s\n",b[i]);
		}
	}
	return 0; 
}

Double click to view unformatted code.


Back to problem 97