From 413d751eee14c951b9174e9124d7d59ee4a71d41 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sat, 19 Jun 2004 22:09:01 +0000 Subject: [PATCH] * Ordeno el Z en forma dinamica --- otros/mtf/mtf.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/otros/mtf/mtf.c b/otros/mtf/mtf.c index 6d59e9b..5c19a12 100644 --- a/otros/mtf/mtf.c +++ b/otros/mtf/mtf.c @@ -16,6 +16,15 @@ void print_z(char *z, int len) printf("\n"); } +int comparar(const void *d1, const void *d2) +{ + char *c1, *c2; + + c1 = (char *)d1; + c2 = (char *)d2; + + return (*c1) - (*c2); +} int *jacu_mtf(char *datos, int len) { @@ -28,7 +37,10 @@ int *jacu_mtf(char *datos, int len) printf("Z original = "); print_z(z, size); printf("SIZE = %d\n", size); - z[0]='A';z[1]='B';z[2]='C';z[3]='D';z[4]='R'; + /*z[0]='A';z[1]='B';z[2]='C';z[3]='D';z[4]='R';*/ + /* Ordeno */ + qsort(z, size, 1, comparar); + for(i=0; i