X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/b3e6a4ea1908eb3b26a278a8f583ba5d15e06eda..d5a4d5447b65cfb33f907f0422d970ed880d82a6:/otros/mtf/mtf.c?ds=inline diff --git a/otros/mtf/mtf.c b/otros/mtf/mtf.c index 6d59e9b..efd2b72 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,12 @@ 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); + printf("Z ordenado = "); + print_z(z, size); + for(i=0; i