void pop_front(char *z, int pos);
-/*int get_pos(char *z, int len, char c);*/
+int get_pos(char *z, int len, char c);
/****fin privadas******/
void print_z(char *z, int len)
{
int i;
for(i=0; i<len; i++)
- printf("%c", z[i]);
- printf("\n");
-}
-
-int comparar(const void *d1, const void *d2)
-{
- char *c1, *c2;
-
- c1 = (char *)d1;
- c2 = (char *)d2;
-
- return (*c1) - (*c2);
+ fprintf(stderr, "%c", z[i]);
+ fprintf(stderr, "\n");
}
int *jacu_mtf(char *datos, int len)
pos = (int*)malloc(len*sizeof(int));
z = jacu_buscar_z(datos, len, &size);
- 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';*/
- /* Ordeno */
- qsort(z, size, 1, comparar);
- printf("Z ordenado = ");
- print_z(z, size);
-
for(i=0; i<len; i++){
pos[i] = get_pos(z, size, datos[i]);
- printf("vino %c emiti: %d\n",datos[i], pos[i]);
if (pos[i] != 0)
pop_front(z,pos[i]);
- print_z(z, size);
}
return pos;
}
char *z;
int i, j=0;
- z = NULL; /*(char*)malloc(1);*/
- /*if (z==NULL) return NULL;*/
+ z = NULL;
for(i=0; i<len; i++){
if( no_pertenece(z, datos[i], j) == -1 ){
j++;