From: Ricardo Markiewicz Date: Sat, 19 Jun 2004 23:02:53 +0000 (+0000) Subject: Reestructuracion X-Git-Tag: svn_import~146 X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/commitdiff_plain/1be06ef7e219504dbdc7b31d461e95ed3ca72bbd?ds=inline Reestructuracion --- 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; -} - - diff --git a/otros/blocksorting/main.c b/otros/blocksorting/main.c new file mode 100644 index 0000000..3df6d8a --- /dev/null +++ b/otros/blocksorting/main.c @@ -0,0 +1,46 @@ + +#include "bs.h" + +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; +} + +