谁来帮我解释这段程序?

来源:百度知道 编辑:UC知道 时间:2024/05/08 12:01:24
#include<stdio.h>

struct fsb
{
int data;
int flag;
struct fsb * next;
};
main()
{
struct fsb *p,*head,*sta,*end;
int i,cishu,j;
end=(struct fsb *)malloc(sizeof(struct fsb));
end->data=0;
end->flag=0;
end->next=NULL;
head=p=end;

for (i=2;i<=10;i++)
{
end=(struct fsb *)malloc(sizeof(struct fsb));
end->data=i-1;
end->flag=0;
end->next=NULL;
p->next=end;
p=end;
}
p->next=NULL;
printf("\n倒序前:");
p=head;
for(i=1;i<=10;i++)
{
printf("%d ",p->data);
p=p->next;
}
/*************************/
p=NULL;
while(head->next != NULL)
{
sta=head;
head=head->next;
sta->next=p;
p=sta;
}
head->next=sta;
printf("\n倒序后:&qu

#include<stdio.h>

struct fsb
{
int data;
int flag;
struct fsb * next;
};
main()
{
struct fsb *p,*head,*sta,*end; int i,cishu,j; /*初始化链表 头节点值为0*/

end=(struct fsb *)malloc(sizeof(struct fsb));
end->data=0;
end->flag=0;
end->next=NULL;
head=p=end;

for (i=2;i<=10;i++) /*创建10个节点链表 节点值依次为0—9*/

{
end=(struct fsb *)malloc(sizeof(struct fsb));
end->data=i-1;
end->flag=0;
end->next=NULL;
p->next=end;
p=end;
}
p->next=NULL;
printf("\n倒序前:"); /*输出10个节点值*/
p=head;
for(i=1;i<=10;i++)
{
printf("%d ",p->data);
p=p->next;
}
/*************************/
p=NULL; /*P置空*/
while(head->next != NULL) /*将链表倒叙*/
{
sta=head; /*sta指向当前head指向的节点,第一次head指向链表头节点*/
head=head->next; /*head指向下一节点*/
sta->