摘要: template Error_code List :: remove( int position , List_entry &x) { if (count == 0) return underflow ; if (position =count) return range_error ; x = entry[position ];/X是被删除的元素 count −−; while (position < count){ entry[position] = entry[position+1]; position++ ; } return success;} 阅读全文
posted @ 2013-09-26 18:32 XTQ 阅读(154) 评论(0) 推荐(0)
摘要: The constructor Listtemplate List :: List( ) { count = 0; }cleartemplate voidList :: clear( ) { count = 0; }emptytemplate boolList :: empty( ) const { return count boolList :: full( ) const { return count >=max_list; }replacetemplate Error_code List :: replace( int position , const List_en... 阅读全文
posted @ 2013-09-26 18:29 XTQ 阅读(389) 评论(0) 推荐(0)
摘要: 1.栈的定义:栈是一种数据结构,一种只能在一端进行插入和删除操作的特殊线性表。2.它按照后进先出的原则存储数据,先进入的数据被压入栈底,最后的数据在栈顶,需要读数据的时候从栈顶开始弹出数据,最后一个数据被第一个读出来。允许在同一端进行插入和删除操作的特殊线性表。允许进行插入和删除操作的一端称为栈顶(top),另一端为栈底(bottom);栈底固定,而栈顶浮动;栈中元素个数为零时称为空栈。插入一般称为进栈(PUSH),删除则称为退栈(POP)。栈也称为后进先出表。3。关于队列:队列是一种特殊的线性表,它只允许在表的前端(front)进行删除操作,而在表的后端(rear)进行插入操作。进行插入操作 阅读全文
posted @ 2013-09-05 19:35 XTQ 阅读(293) 评论(0) 推荐(0)
摘要: #include#include#include"Stack.h"const int maxstack=31;enum Error_code{success,overflow,underflow};typedef int Stack_entry;class Stack{bool empty() const;Error_code copy_stack(Stack&dest,Stack&source);private:int count;Stack_entry[maxstack];};bool Stack::copy_stack(Stack&dest,c 阅读全文
posted @ 2013-08-29 20:30 XTQ 阅读(155) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;const int maxqueue=30;enum Error_code{success,underflow,overflow};typedef int Queue_entry;class Queue{public:Queue();bool empty()const;Error_code serve();Error_code append(const Queue_entry&item);Error_code retrieve(Queue_entry&item)const;protected:int cou 阅读全文
posted @ 2013-08-29 20:29 XTQ 阅读(178) 评论(0) 推荐(0)