From 79c3f2200fb945762a764093f545ce61edf691c8 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sat, 19 Jun 2004 21:05:00 +0000 Subject: [PATCH] * Agrego bs_restore para rehacer el array original. --- otros/blocksorting/bs.c | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/otros/blocksorting/bs.c b/otros/blocksorting/bs.c index 61dfb78..13b7824 100644 --- a/otros/blocksorting/bs.c +++ b/otros/blocksorting/bs.c @@ -18,6 +18,20 @@ typedef struct _bs_t_ { unsigned long int len; } t_BlockSort; +typedef struct _bs_decode_t_ { + char c; + unsigned long int pos; +} t_BlockSortDecode; + +int _compare(const void *d1, const void *d2) { + t_BlockSortDecode *s1, *s2; + + s1 = (t_BlockSortDecode *)d1; + s2 = (t_BlockSortDecode *)d2; + + return (s1->c - s2->c); +} + char es_menor(char *data, t_BlockSort *bs, int i, int j) { unsigned long int pi, pj, k; @@ -88,6 +102,29 @@ void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsign bs->len = l; } +void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len) +{ + unsigned long int i, current; + t_BlockSortDecode *in; + + in = malloc(sizeof(t_BlockSortDecode)*len); + + for(i=0; i \n", argv[0]); return 0; @@ -126,8 +163,9 @@ int main(int argc, char *argv[]) len = atoi(argv[2]); data = malloc(sizeof(char)*len); - salida = malloc(sizeof(char)*len); + salida = malloc(sizeof(char)*(len+1)); + salida[len] = '\0'; bs = bs_create(len); while ((c = fgetc(fp)) != EOF) { @@ -139,6 +177,7 @@ int main(int argc, char *argv[]) bs_solve(data, salida, bs, &k, i); /* XXX ACA SALIDA DEBERIA PASAR A LA SIGUIENTE ETAPA XXX */ + printf("%s -> %ld\n", salida, k); } fclose(fp); bs_destroy(bs); -- 2.43.0