数据结构算法设计题:单循环链表中删除表中所有数值相同的多余元素

来源:百度知道 编辑:UC知道 时间:2024/09/22 20:15:52
算法设计题:单循环链表中删除表中所有数值相同的多余元素

//算法设计题:单循环链表中删除表中所有数值相同的多余元素
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define OK 1
#define Status int
typedef struct LNode
{
int data;
LNode *next;
}LNoed,*LinkList;
Status CreateList_L(LinkList &L)
{
int n,i;
LinkList p,q;
printf("input the length of the List\n");
scanf("%d",&n);
printf("input the data\n");
L=(LinkList)malloc(sizeof(LNode));
q=L;
scanf("%d",&L->data);
//L->next=NULL;
for(i=2;i<=n;i++)
{
p=(LinkList)malloc(sizeof(LNode));
scanf("%d",&p->data);
q->next=p;
//p->next=NULL;
q=p;
}
p->next=L;

return OK;
}
Status OutList_L(LinkList L)
{
printf("the List is\n");
LinkList p;
p=L;
do
{
printf("%4d",p-&