2011年10月22日

(链表实现)写出两个一元多项式相加的算法

摘要: /*实验23. 试写出两个一元多项式相加的算法。用链表来存储一元多项式,并且要在程序中验证其功能实现。此题的源程序保存为2_e1.cpp*/#include<iostream>using namespace std;struct node{ int co; //系数 int exp; //指数 struct node * next;};node* Creat() {//尾插法建表,有头结点 node* head; node* s, *p; int c, e; head=new node; //生成头结点 head->next=NULL; cout<<"请 阅读全文

posted @ 2011-10-22 10:06 1.曲待续 阅读(9498) 评论(0) 推荐(0) 编辑

顺序栈

摘要: /*实验22. 完成对顺序栈结构的定义,以及对顺序栈的各种基本运算的实现(每种基本运算用一个函数来实现)。基本运算包括:初始化Init_sqstack运算、判栈空Empty_sqstack运算、入栈Push_sqstack运算、出栈Pop_sqstack运算、取栈顶元素Gettop_sqstack运算。并且在main函数中分别调用以上各种基本运算的函数来使用,以证明其功能已实现。此题的源程序保存为 3_a1.cpp。*/#include<iostream>using namespace std;typedef char datatype; //栈元素类型,假设为整型const in 阅读全文

posted @ 2011-10-22 10:04 1.曲待续 阅读(228) 评论(0) 推荐(0) 编辑

写一个函数DeleteRange删除单链表中结点的值在low 和high之间的结点

摘要: /*实验21. 写一个函数DeleteRange删除单链表中结点的值在low 和high之间的结点(low和high的值是多少可自由设计)。并且要在程序中验证其功能实现。(可在实验1的第3题的基础上增加此功能)。此题的源程序保存为 2_a4.cpp。*/#include<iostream>using namespace std;typedef char datatype;typedef struct node* pointer;struct node{ datatype data; pointer next;};typedef node* lklist;lklist Creat() 阅读全文

posted @ 2011-10-22 10:03 1.曲待续 阅读(535) 评论(0) 推荐(0) 编辑

单链表

摘要: /*3. 按照课本第2.3.1节定义的单链表结构,完成对单链表结构的定义,以及对单链表的各种基本运算的实现(每种基本运算用一个函数来实现)。基本运算包括:建表Create运算、初始化InitList运算、求表长Length运算、插入新节点Insert运算、删除节点Delete运算、按序号查找Get运算、定位(按值查找)Locate运算、输出单链表中所有结点的数据元素值Display运算、销毁Destroy运算。*/#include<iostream>using namespace std;typedef char datatype;typedef struct node* poin 阅读全文

posted @ 2011-10-22 09:58 1.曲待续 阅读(226) 评论(0) 推荐(0) 编辑

(顺序表)设计算法删除所有数字字符

摘要: /*2. 一个顺序表中存放字符(只有数字字符和英文字符), 编写算法删除所有的数字字符*/#include<iostream>using namespace std;typedef char datatype;const int maxsize = 100;typedef struct { datatype data[maxsize]; int n;}sqlist; sqlist* InitList(){ sqlist *L=new sqlist; L->n=0; return L;} int Length(sqlist * L){ return L->n;}int I 阅读全文

posted @ 2011-10-22 09:55 1.曲待续 阅读(476) 评论(0) 推荐(0) 编辑

导航