为什么不能输出当i==3时的链表,多谢

为什么不能输出当i==3时的链表,谢谢
#include<stdio.h>
#include<stdlib.h>
struct student{
int xuehao;

struct student *next;
};
void disp(struct student *head)
{
struct student *p=head->next;
while(p!=NULL)
{
printf("%d ",p->xuehao);

p=p->next;
}
}
struct student *cj()
{
struct student *head,*pnew,*p;
int i=0,k;

head=(struct student *)malloc(sizeof(struct student));
head->next=head;
p=head;

if(head==NULL)
return NULL;
while(i<5)
{
printf("input xuehao");
scanf("%d",&k);


i++;
pnew=(struct student *)malloc(sizeof(struct student));
if(pnew==NULL)
return NULL;
pnew->xuehao=k;

pnew->next=p->next;
p->next=pnew;
p=pnew;

}
return head;
}
void pp(struct student *head)
{
int i=0,k=5;
struct student *head1,*p=head,*pnew,*t,*q;
head1=(struct student *)malloc(sizeof(struct student));
t=head1;
head1->next=NULL;
while(k<1)
{

p=p->next;
i++;
if(i==3)
{

pnew=(struct student *)malloc(sizeof(struct student));
pnew->next=t->next;
pnew->xuehao=p->xuehao;
t->next=pnew;
t=pnew;
i=0;
k--;
q=p->next;
p->next=p->next->next;
free(q);


}

}
disp(head1);
}
void main()
{
struct student *head;
head=cj();

printf("\n\n");

pp(head);
}


------解决方案--------------------