正在加载图片...
printf("请输入第‰个数:",i+1) scanf(%d", &e) InsertList(LB, e) Print (lB) /*将LA输出* Guibing(LA, LB, Lc) //将大于6小于9地元素删除 Print(lc) /*将逆置后结果输出*/ 2.9/*P49习题2.8示例程序* #include <stdio. h> #include <stdlib. h> #define null o typedef int ElemType: typedef struct node ElemType data struct node * next }Node,米 Linklist *向环行链表中插入元素*/ void Insertlist (linklist *ph, ElemType e) p=(LinkList)malloc(sizeof (Node)) >data=e if(pH = NULL) e p->next =(*pH)->next (*pH)->next p //删除H所指结点的前一个结点 void Delete (linkList H, int *pe f(H->next==H)//若环行链表中只有一个结点,则返回 return{ printf("请输入第 %d 个数:",i+1); scanf("%d",&e); InsertList(LB,e); } Print(LB); /*将 LA 输出*/ Guibing(LA, LB, LC); //将大于 6 小于 9 地元素删除 Print(LC); /*将逆置后结果输出*/ } 2.9 /*P49 习题 2.8 示例程序 */ #include <stdio.h> #include <stdlib.h> #define NULL 0 typedef int ElemType; typedef struct node { ElemType data; struct node *next; }Node,*LinkList; /*向环行链表中插入元素*/ void InsertList(LinkList *pH,ElemType e) { LinkList p; p=(LinkList)malloc(sizeof(Node)); p->data=e; if(*pH == NULL) { p->next = p; *pH = p; } else { p->next = (*pH)->next; (*pH)->next = p; } } //删除 H 所指结点的前一个结点 void Delete(LinkList H, int *pe) { LinkList p, t; if(H->next == H) //若环行链表中只有一个结点,则返回 return;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有