.
6.11 退出程序
图6.11退出程
七 源代码
#include
char coef;
.
.
struct set *next; }; //线性表的单链表存储结构
void createlist_p(struct set *&p,int n) {
int i;
struct set *L;
p=(struct set *)malloc(sizeof(set)); p->next=NULL; //建立一个带头结点的单链表
{
for(i=n;i>0;i--)
L=(struct set *)malloc(sizeof(set)); //生成新节点 printf(\请输入该集合中第%d个整数元素:\ scanf(\ L->next=p->next; p->next=L; //插入到表头 }
void printlist_p(struct set *&p) {
}
.
.
struct set *L; int i; L=p->next;
if(!L) printf(\该表为空!\\n\ while(L!=NULL) {
printf(\ L=L->next; i++; }
printf(\}
void Addset(struct set *&p,struct set *&q,struct set *&r) {
struct set *k,*m,*n;
r=(struct set *)malloc(sizeof(set)); r->next=NULL; k=p->next;
for(;k;)
.
.
{
m=(struct set *)malloc(sizeof(set)); m->next=r->next; r->next=m; m->coef=k->coef; k=k->next; //r中存放p }
k=q->next;
m=(struct set *)malloc(sizeof(set)); m->next=r->next; r->next=m; m->coef=k->coef; k=k->next;
for(;k;) {
for(n=r->next;(k->coef!=n->coef)&&n->next;)
{
n=n->next;
.
.
}
if((k->coef!=n->coef)&&!(n->next))
{
m=(struct set *)malloc(sizeof(set)); m->next=r->next; r->next=m; m->coef=k->coef;
}
k=k->next; }
}//求A∪B
void Subset(struct set *&p,struct set *&q,struct set *&r) {
struct set *k,*m,*n;
r=(struct set *)malloc(sizeof(set)); r->next=NULL; n=q->next; for(;n;) {
m=p->next;
for(;(m->coef!=n->coef)&&m->next;)
.