高分跪求答案,C语言,这题什么讲的是什么啊?大侠帮帮忙吧,谢谢了

以下程序运行后输出结果的第一行为________,第二行为________,第三行为_________
#include<stdio,h>
#include<stdlib.h>
struct node
{ char data;struct node *next;};

struct node *insert(struct node *h,char c)
{ struct node *p,*p1,*p2;
p=(struct node *)malloc(sizeof(struct node)); p->data=c;p->next=NULL;
if(h==NULL)h=p;
else
{ p1=p2=h;
while(c>p1->data&&p1->next!=NULL) { p2=p1;p1=p1->next;}
if(c<=p1->data)
if(p1==h) { p->next=h;h=p;}
else { p2->next=p;p->next=p1;}
else { p1->next=p;}
}
return h;
}

struct node *del(struct node *h)
{
struct node *p=h;
while(p!=NULL)
{ if(p->data%2==0) p->next=p->next->next;
p=p->next;
}
return h;
}

void printf(struct node *h)
{ struct node *p=h;
while(p!=NULL)
{ printf("%c",p->data); p=p->next;
printf("\n");
}

void main()
{ struct node *head=NULL; char *item="32659",*p=item;
puts(item);
while(*p) head=insert(head,*p++);
print(head); del(head); print(head);
}
答案是32659
23569
256

struct node
{ char data;struct node *next;}; /*此段定义了一个结构,该结构体有两个变量一个是char字符,一个指向下一个node类型变量的指针,相当于一个向后的链表。*/

struct node *insert(struct node *h,char c) //函数定义,返回一个node类型的指针,变量是一个node类型的地址,一个字符c*/
{ struct node *p,*p1,*p2;
p=(struct node *)malloc(sizeof(struct node));//分配内存地址
p->data=c;p->next=NULL; //初始化,P的data为变量c,next指针为空
if(h==NULL)h=p; //如果输入的指针为空,那么把p付给h,返回
else //该段代码用于排序,从小到大
{ p1=p2=h;
while(c>p1->data&&p1->next!=NULL) { p2=p1;p1=p1->next;} /*如果c大于P1中的数据且下一数据不为空,继续遍历,p1指向下一个h中下一个数据,否则跳出循环*/
if(c<=p1->data) //小于等于时插入数据
if(p1==h) { p->next=h;h=p;} //此处的h和p都是内存地址
else { p2->next=p;p->next=p1;}
else { p1->next=p;}//否则加到最后
}
return h;
}

struct node *del(struct node *h)
{
struct node *p=h;
while(p!=NULL)
{ if(p->data%2==0) p->next=p->next->next; /*如果当前字符时偶数(ASCII表),那么p的next指针指向下个数据的next指向的地址;重复直到结束*/
p=p->next;
}
return h;
}

void printf(struct node *h)
{ struct node *p=h;
while(p!=NULL)
{ printf("%c",p->data); p=p->next; //打印
printf("\n");
}

void main()
{ struct node *head=NULL; char *item="32659",*p=item;
puts(item);
while(*p) head=insert(head,*p++);
print(head); del(head); print(head);
}
答案是32659
23569
256
温馨提示:答案为网友推荐,仅供参考
相似回答