#include<stdio.h>
#include<malloc.h>
struct linknode
{
int a;
struct linknode *next;
};
struct linknode *creatnode()
{
struct linknode *p;
p=(struct linknode *)malloc(sizeof(struct linknode));
int a;
scanf("%d",&a);
p->a;
p->next=NULL;
return p;
}
void insertfirst(struct linknode *head,struct linknode *p)
{
struct linknode *p1;
if(head==NULL)
{
head=p;
}
else
{
p1=head;
head=p;
p->next=p1;
}
}
void insertlast(struct linknode *head,struct linknode *p)
{
struct linknode *p1,*p2;
int a;
p1=head;
while(p1->next!=NULL)
{
p2=p1;
p1=p2->next;
}
p1->next=p;
}
void displink(struct linknode *head)
{
struct linknode *py;
py=head;
while(py!=NULL)
{
printf("%d ",py->a);
py=py->next;
}
}
void freelink(struct linknode *head)
{
struct linknode *node;
while(head!=NULL)
{
node=head->next;
free(head);
head=node;
}
}
int main()
{
int n;
scanf("%d",&n);
struct linknode *head,*p;
head=creatnode();
int i;
for(i=2;i<=n;i++)
{
p=creatnode();
if(i%2!=0)
{
insertfirst(head,p);
}
else
{
insertlast(head,p);
}
}
displink(head);
freelink(head);
return 0;
}
请问这是个啥情况