Mercurial > hg > Members > nobuyasu > CbC
changeset 20:12fe1bbe8b4f draft
modify test-huffman.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 01 Aug 2012 19:36:27 +0900 |
parents | a21df07434f2 |
children | 42f3a796c0be |
files | Huffman/test-huffman.c |
diffstat | 1 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Huffman/test-huffman.c Tue Jul 31 13:35:20 2012 +0900 +++ b/Huffman/test-huffman.c Wed Aug 01 19:36:27 2012 +0900 @@ -8,6 +8,7 @@ int parent[2*N]; int l_node[2*N], r_node[2*N]; + void q_sort(int* numbers[], int left, int right) { int pivot, l_hold, r_hold; @@ -63,10 +64,21 @@ quick_sort(numbers, N); - for (i=0; i<N; i++) { - printf("%d ",*numbers[i]); + + int node[2*N]; + int node_count = 0; + int *prev_node; + for (i=0; i<2*N; i++) node[i] = 0; + + // make tree. + for (i=0; i<N; i++ ) { + if (*numbers[i] == 0) continue; + + node[node_count] = numbers[i]; + + } - puts(""); + return 0; } @@ -77,7 +89,7 @@ { FILE *fp; - char *filename = "./test.txt"; + char *filename = "./sample.txt"; if ( (fp = fopen( filename,"r")) == NULL ) { fprintf(stderr, "Can't open file %s\n", filename); exit(0); @@ -95,7 +107,6 @@ encode(buf, n_chars); - /* while ( (ret = (int)*buf) != '\0' ) { putc(*buf,stdout);