#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 10
typedef struct node
{
char name[20];
struct node *llink,*rlink;
}stud;/*双链表的结构定义*/
/*双链表的创建*/
stud * creat(int n)
{
stud *p,*h,*s;
int i;
if((h=(stud *)malloc(sizeof(stud)))==NULL)
{
printf("cannot find space!\n");
exit(0);
}
h->name[0]='\0';
h->llink=NULL;
h->rlink=NULL;
p=h;
for(i=0;i<n;i++)
{
if((s= (stud *) malloc(sizeof(stud)))==NULL)
{
printf("cannot find space!\n");
exit(0);
}
p->rlink=s;
printf("Please input the %d man's name: ",i+1);
scanf("%s",s->name);
s->llink=p;
s->rlink=NULL;
p=s;
}
h->llink=s;
p->rlink=h;
return(h);