//c语言之双向循环链表
#include<stdio.h>
#include<malloc.h>
typedef struct Student{
int data;
struct Student *Next;
struct Student *Prior;//
}*PNode,Node;
PNode creatlist(){
PNode head,rear,node;
printf("请输入链表的值");
head=(PNode)malloc(sizeof(Node));
rear=head;
int n;
scanf("%d",&n);
while(n!=0){
node=(PNode)malloc(sizeof(Node));
node->data=n;
rear->Next=node;
node->Prior=rear;
rear=node;
scanf("%d",&n);
}
head->Prior=rear;
rear->Next=head;
return head;
}
void printflist(PNode x){
PNode p=x->Prior;
PNode head=x;
printf("p:%p\n",p);
printf("x:%p\n",x);
while(p!=head){
printf("%d ",p->data);
p=p->Prior;
}
}
int main(){
PNode x=creatlist();
printf("\n");
printflist(x);
return 0;
}
c语言之双向循环链表
最新推荐文章于 2024-01-14 23:42:18 发布