/ * Huffman Coder & Decoder * /
Include
HT0 [I-1] .lch = flag [1-1] .Num; ht0 [i-1] .RCH = flag [2-1] .num; ht0 [i-1] .weight = ht0 [flag [1 -1] .NUM-1] .Weight HT0 [FLAG [2-1] .NUM-1] .weight;} / ** / for (i = 0; i <= n; i ) cd.bits [i -1] = 0; for (r = 1; r <= n; R ) {cd.start = n; c1 = r; sgn = HT0 [C1-1] .parent; while (sgn) {ix (ht0 [ SGN-1] .LCH == C1) CD.BITS [CD.Start-1] = 0; ELSE IF (HT0 [SGN-1] .rch == C1) CD.BITS [CD.Start-1] = 1 Cd.start -; c1 = SGN; SGN = HT0 [SGN-1] .parent;} HCD0 [R-1] = Cd;}} / ** / void table (Struct Nodetype HT [], Struct CodeType HCD []) {INT I, J; Create (HT, HCD); for (i = 1; i <= n; i ) {Printf ("/ n% C / T", HT [I-1] .data) For (j = HCD [i-1] .start 1; j <= n; j ) {printf ("% D", HCD [i-1] .bits [j-1]);}}} / ** / void code (Node HT2 [], Code HCD2 []) {char str1 [max]; int H, i, j, k = 0; Create (HT2, HCD2); Printf ("/ n / t Please enter Text: / n "); for (h = 0; (str1 [h] = getchar ())! = '#'; H ); / * great !!!!!!!!!!!! * / while (STR1 [K]! = 0) {for (i = 1; i <= n; i ) IF (HT2 [I-1] .data == STR1 [K]) for (j = HCD2 [i-1] .Start 1; J <= n; j ) Printf ("% d", HCD2 [i-1] .bits [j-1]); k ;} printf ("/ n / t / t wow! too happy ");} / ** / void decoding (Node HT3 [], Code HCD3 [ ]) {char * str2 = ""; Node Q; Create (HT3, HCD3); Printf ("/ t / t Please enter encoding: / n"); scanf ("% s", str2); while (* str2 ) {= HT3 [M-1]; while (q.lch! = 0) {if (* str2 == '0') {q = HT3 [q.LCH-1]; str2 ;} else if (* STR2 == '1') {q = HT3 [q.rch-1]; str2 ;}} printf ("% c", q.data);} printf ("/ n / t / t call! Know that 01 is really romantic :) ")");} / ** / void main () {char ctrl, ctrl1, ctrl2; int i = 0;