X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/d02652e3b6a0c912464d28cd6cd966c26ac4dc37..d5a4d5447b65cfb33f907f0422d970ed880d82a6:/otros/mtf/mtf.c?ds=sidebyside diff --git a/otros/mtf/mtf.c b/otros/mtf/mtf.c index dd0c8ab..efd2b72 100644 --- a/otros/mtf/mtf.c +++ b/otros/mtf/mtf.c @@ -1,7 +1,7 @@ #include "mtf.h" /****privadas*****/ -int no_pertenece(char *z, char c); +int no_pertenece(char *z, char c, int len); void pop_front(char *z, int pos); @@ -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