链表问题求助帮忙 大佬们来帮忙看看吧

#include <stdio.h>
#include <stdlib.h>
#define LED sizeof(struct student)
struct student
{
int num1;
int num2;
struct student *next;
};
void main ()
{
int n,i;
struct student *head;
struct student *p,*p1,*p2;
p1=p2=(struct student *)malloc(LED);
scanf ("%d%d",&(*p1).num1,&p1->num2);
head=NULL;
n=0;
while (p1->num1!=0)
{
n++;
if (n1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *)malloc(NULL);
scanf ("%d%d",&(*p1).num1,&p1->num2);
}
p=head;
for (i=1;p->num1!=0;)
{
if(p->num2!=3)
{
p->num2=i;
p=p->next;
i++;
if (i
4)
i=1;
}
else
{
p=p->next;
}
}
p=head;
//输出不是3的序号

while (p->num1!=0)
{
	if (p->num2!=3)
		printf ("编号%d 报数%d\n",p->num1,p->num2);
	p=p->next;
}
system ("pause");

}

这个程序让我很头疼 链表问题
运行之后
在这里插入图片描述
就是这种情况
大佬们可以帮忙看看有啥问题吗
太难了 在家想了两天

发布了1 篇原创文章 · 获赞 0 · 访问量 54

猜你喜欢

转载自blog.csdn.net/weixin_45531394/article/details/104389567