文档详情

huffman算法报告.docx

发布:2017-12-15约1.05万字共23页下载文档
文本预览下载声明
huffman压缩软件的实现utility.h加入到工程中。其代码如下:#includestring.h //standard string operations#includeiostream.h //standard iostream operations#includelimits.h //numeric limits#includemath.h //mathematical functions#includefstream.h //file input and output#includectype.h //character classification#includetime.h //date and time function#includeconio.h //con input and output#includestdlib.h //standard libray#includestdio.h //standard I/O librayenum Error_code{success,fail,underflow,overflow,range_error};//enum bool{false,true}lk_stack.h的内容:templateclass Node_entrystruct Node {// data members Node_entry entry; NodeNode_entry *next;// constructors Node(); Node(Node_entry item, NodeNode_entry *add_on = NULL);};templateclass Stack_entryclass Stack {public:// Standard Stack methods Stack(); bool empty() const; Error_code push(const Stack_entry item); Error_code pop(); Error_code top(Stack_entry item) const; void clear();// Safety features for linked structures ~Stack(); Stack(const StackStack_entry original); void operator =(const StackStack_entry original);protected: NodeStack_entry *top_node;};templateclass Node_entryNodeNode_entry::Node(){ next = NULL;}templateclass Node_entryNodeNode_entry::Node(Node_entry item, NodeNode_entry *add_on){ entry = item; next = add_on;}templateclass Stack_entryStackStack_entry::Stack(){ top_node=NULL;}templateclass Stack_entrybool StackStack_entry::empty() const{ if(top_node==NULL) return true; else return false;}templateclass Stack_entryError_code StackStack_entry::push(const Stack_entry item)/*Post: Stack_entry item is added to the top of the Stack; returns success or returns a code of overflow if dynamic memory is exhausted.*/{ NodeStack_entry *new_top = new NodeStack_entry(item, top_node); if (new_top == NULL) return overflow; top_node = new_top; return success;}templateclass Stack_entryError_code StackStack_entry::pop()/*Post: The top of the Stack is removed. If the Stack is empty the method returns underflow; otherwise it returns success.*/{
显示全部
相似文档