#include <stdio.h> #include <string.h> typedef struct node{ char ch[4][20]; }xe; typedef struct tode{ char ch[3][20]; }nxe; int comp(const void* a,const void* b) { xe* c = (xe*)a; xe* d = (xe*)b; return strcmp(c->ch[0],d->ch[0]); } int main(void) { char str[100],ch[3][20]={"1","1","1"}; int n; while(scanf("%d",&n) != EOF && n) { int i,j,k,index1 = 0,index2 = 0; xe exe[1000]; nxe nexe[1000]; for(i = 0;i < n;i++) { scanf("%s",str); sscanf(str,"%[^.].%[^.].%[^.]",ch[0],ch[1],ch[2]); if(strcmp(ch[2],"1") == 0 && strcmp(ch[1],"1") == 0) { strcpy(nexe[index1].ch[0],ch[0]); strcpy(nexe[index1].ch[1],"\0"); index1++; strcpy(ch[0],"1"); } else if(strcmp(ch[2],"1") == 0 && strcmp(ch[1],"1") != 0) { strcpy(nexe[index1].ch[0],ch[0]); strcpy(nexe[index1].ch[1],ch[1]); index1++; strcpy(ch[0],"1"); strcpy(ch[1],"1"); } else if(strcmp(ch[2],"exe") == 0) { strcpy(exe[index2].ch[0],ch[0]); strcpy(exe[index2].ch[1],ch[1]); strcpy(exe[index2].ch[2],ch[2]); strcpy(ch[2],"1"); strcpy(ch[0],"1"); strcpy(ch[1],"1"); index2++; } } qsort(exe,index2,sizeof(xe),comp); for(j = 0;j < index2;j++) { for(k = 0;k < index1;k++) { if(strcmp(exe[j].ch[0],nexe[k].ch[0]) == 0 && strcmp(exe[j].ch[1],nexe[k].ch[1]) == 0) { printf("%s.%s.%s\n",exe[j].ch[0],exe[j].ch[1],exe[j].ch[2]); break; } } } } return 0; } |
Double click to view unformatted code.