X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/79c3f2200fb945762a764093f545ce61edf691c8..8f161fb90db32293100c689806720acde9844b00:/otros/blocksorting/bs.c diff --git a/otros/blocksorting/bs.c b/otros/blocksorting/bs.c index 13b7824..bf39971 100644 --- a/otros/blocksorting/bs.c +++ b/otros/blocksorting/bs.c @@ -1,22 +1,7 @@ -/* Block Sorting Optimizado en memoria! */ - -#include -#include -#include - -typedef struct _bs_data_t_ { - unsigned long int pos_inicial; - unsigned long int pos_final; - unsigned long int pos_orden; - char ord; /* indice si esta ordenada */ -} t_BlockSortData; +#include "bs.h" -typedef struct _bs_t_ { - t_BlockSortData *array; - unsigned long int *ord; - unsigned long int len; -} t_BlockSort; +/* Block Sorting Optimizado en memoria! */ typedef struct _bs_decode_t_ { char c; @@ -125,7 +110,7 @@ void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len) free(in); } -t_BlockSort *bs_create(unsigned int len) +t_BlockSort *bs_create(unsigned long int len) { t_BlockSort *tmp; @@ -145,46 +130,3 @@ void bs_destroy(t_BlockSort *bs) free(bs); } -int main(int argc, char *argv[]) -{ - char *data; - char *salida; - unsigned long int len, i, k; - FILE *fp; - char c; - t_BlockSort *bs; - - if (argc != 3) { - printf("Modo de uso : %s \n", argv[0]); - return 0; - } - - fp = fopen(argv[1], "r"); - len = atoi(argv[2]); - - data = malloc(sizeof(char)*len); - salida = malloc(sizeof(char)*(len+1)); - - salida[len] = '\0'; - bs = bs_create(len); - - while ((c = fgetc(fp)) != EOF) { - i = 0; - while ((c!=EOF) && (i < len)) { - data[i++] = c; - c = fgetc(fp); - } - 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); - - free(data); - free(salida); - return 0; -} - -