int main(int argc, char *argv[] )
{
char buff[BUFFER_SIZE];
+ char *z, *dato;
int *pos;
int len;
- int i;
+ int i, size;
+
len = fread(buff, 1, BUFFER_SIZE, stdin);
buff[len] = '\0';
-
pos = jacu_mtf(buff, len);
+ for(i=0; i<len; i++)
+ printf("%d ",pos[i]);/*putchar(pos[i]);*/
+ printf("\n-----Inversa del MTF-----\n");
+ z = jacu_buscar_z(buff, len, &size);
+ dato = jacu_mtf_inv(z, pos, len);
for(i=0; i<len; i++)
- putchar(pos[i]);
+ putchar(dato[i]);
+ free(dato);
+ free(z);
free(pos);
return 0;
}
-
return pos;
}
+char *jacu_mtf_inv(char *z, int *pos, int len)
+{
+ char *datos;
+ int i;
+
+ datos = (char*)malloc(sizeof(char)*len);
+ for(i=0; i<len; i++){
+ datos[i] = z[pos[i]];
+ pop_front(z,pos[i]);
+ }
+ return datos;
+}
char *jacu_buscar_z(char* datos, int len, int *size)
{
int *jacu_mtf(char *datos, int len);
+char *jacu_mtf_inv(char *z, int *pos, int len);
+
char *jacu_buscar_z(char* datos, int len, int *size);
#endif