View Code of Problem 97

#include <stdio.h>
#include <math.h>
#include <string.h>
 int main(){
	int n;
	while(scanf("%d",&n)!=EOF&&n!=0){
		char a[n][100];
		char b[n][100];
		char temp[100];
		int x=0;
		for(int i=0;i<n;i++){
			scanf("%s",a[i]);
		}
		for(int 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(int j=0;j<n;j++){
					if(strcmp(temp,a[j])==0){
						strcpy(b[x],a[i]);
						x++;
						break;
					}
					
				}
			}	
		}
		 for(int i=0;i<x-1;i++){
            for(int j=x-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(int i=0;i<x;i++){
			puts(b[i]);
		}		
	}
}	
 

Double click to view unformatted code.


Back to problem 97