用C语言编写一个删除单链表中重复的结点的程序,该怎么写??

如题所述

图片在哪里???
#include

#include

struct
node
{
int
num;
struct
node
*next;
};//定义节点
int
main()
{
struct
node
*p,*temp,*head;
int
i,a=1;
temp=(struct
node
*)malloc(sizeof(struct
node));//开辟一个节点空间
temp->num=a;
head=p=temp;//得到头结点
p->next=null;
for(i=0;i<9;i++)
{
a=a+2;
temp=(struct
node
*)malloc(sizeof(struct
node));
temp->num=a;
temp->next=null;
p->next=temp;
p=p->next;
}
p=head;
for(;p
!=
null;)//打印链表
{
printf("%d,"p->num);
p=p->next;
}
return
0;
}
温馨提示:答案为网友推荐,仅供参考
相似回答