Encodes the character with 01 strings and converts the following 01 strings into corresponding strings
Hit the sample program on the book again.
Reading a single character's function to ignore line breaks or it's magical.
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 Charcode[8][1<<8];6 CharReadchar () {7 while(1){8 CharCh=GetChar ();9 if(ch!='\ n'&&ch!='\ r')returnch;Ten } One } A intReadintintc) { - intv=0; - while(c--) v=v*2+readchar ()-'0'; the returnv; - } - intReadcode () { -memset (Code,0,sizeof(code)); +code[1][0]=Readchar (); - for(intlen=2; len<=7; len++){ + for(intI=0;i< (1<<len)-1; i++){ A CharCh=GetChar (); at if(ch==eof)return 0; - if(ch=='\ n'|| ch=='\ r')return 1; -code[len][i]=ch; - } - } - return 1; in } - intMain () to { + while(Readcode ()) { - while(1){ the intLen=readint (3); * if(!len) Break; $ while(1){Panax Notoginseng intv=Readint (len); - if(v== (1<<len)-1) Break; the Putchar (Code[len][v]); + } A } thePuts""); + } - } $ /* $ TNM Aeiou - 0010101100011 - 1010001001110110011 the 11000 - $#**Wuyi 010000010110110001110010100 the */
UVa 213-message Decoding