#include #include #define INFILE "CONTACT.IN" #define OUTFILE "CONTACT.OUT" #define SIZE 2*4096 #define MAXPAT 16 typedef struct { int index; long val; } Pair; static Pair table[SIZE]; static int MSK[MAXPAT]; void InitPatternTable() { int i,p; p = 0; for(i=0;i>= 1; } s[MAXPAT-1]=0; p = s; while(*p!='1') p++; fprintf(of,p+1); } int LT(Pair a, Pair b) { if(a.val == b.val) return b.index > a.index; else return b.val > a.val; } void Sort(int lo, int up) { int flag, i, j; Pair tempr; i=up-1; while(i>=lo) { tempr = table[i]; j = i+1; flag = 1; while((j<=up) && flag) { if(LT(tempr,table[j])) { table[j-1] = table[j]; j++; } else flag = 0; table[j-1] = tempr; } i--; } } int LT0(Pair *a, Pair *b) { if((a->val) == (b->val)) return b->index - a->index; else { if(a->val > b-> val) return -1; else if(a -> val < b->val) return 1; else return 0; } } typedef int (*ff)(const void *, const void*); void MakeListing(int M, int L,int N) { int i,l; long c; int T = MSK[L]+1; FILE *of; qsort(table+MSK[M-1]+1, MSK[L]-MSK[M-1],sizeof(Pair),(ff)LT0); /* Sort(MSK[M-1]+1,MSK[L]); */ of = fopen(OUTFILE,"w+"); i=MSK[M-1]+1; while(table[i].val==0) i++; for(l=0;(l