#include <stdio.h>
#include <stdlib.h>
#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu{
int num;
int age;
struct stu *prior,*next;
};
TYPE *creat_LinkList(int n){
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;i++){
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if(i==0) pf=head=pb;
else
{
pb->prior=pf;
pf->next=pb;
if(i==n-1){
pb->next=head;
head->prior=pb;
}
}
pf=pb;
}
return(head);
}
int main () {
printf("Hello JSRUN! \n\n - from C .");
struct stu *p ,*pnow;
p = creat_LinkList(4);
pnow = p;
for(int i=0 ; i<4 ; i++)
{
printf("num: %d, age: %d, p: %p, p->next: %p, p->prior: %p\n",pnow->num, pnow->age,pnow,pnow->next,pnow->prior);
pnow=pnow->next;
}
return 0;
}