#include<stdio.h>
#include<stdlib.h>
typedef struct List
{
int * elem;
List * next;
}Note,*Link;
typedef struct Sqr
{
Link front;
Link rear;
}sqr;
void init(sqr &s)
{
s.front=s.rear=(Link)malloc(sizeof(Note));
if(!s.front) exit(0);
s.front->next=NULL;
}
void creat(sqr &s)
{
int i;
for(i=0;i<5;i++)
{
Link p=(Link)malloc(sizeof(Note));// 尼玛 坑爹呀 弄了半天就是分空间出错了(如果把这句放在for循环外面 那么每次赋值就把上次的覆盖了 地址就只有这么一个嘛 )
if(!p) exit(0);
scanf("%d",&p->elem);
p->next=NULL;
s.rear->next=p;
s.rear=p;
}
}
void display(sqr &s)
{
printf("头为: %d\n",s.front->next->elem);
}
void main()
{
sqr s;
init(s);
creat(s);
display(s);
}