请问这个C程序怎么改好

来源:百度知道 编辑:UC知道 时间:2024/05/04 09:36:08
不太会,C和数据结构我连接不上了,有知道的请告诉下,只要给你主函数就可以了
不好意思,忘记写出来了,我另外链接了一个问题,到时候分一起给
http://zhidao.baidu.com/question/89178844

#include <stdio.h>
#include <malloc.h>

typedef char ElemType;

typedef struct LNode
{
ElemType data;
struct LNode *next;
} LinkList;

void InitList(LinkList **L)
{
*L = (LinkList *)malloc(sizeof(LinkList));
(*L)->next = NULL;
}

void DestroyList(LinkList *L)
{
LinkList *p = L,*q = p->next;
while (q != NULL)
{
free(p);
p = q;
q = p->next;
}
free(p);
}
int ListEmpty(const LinkList *L)
{
return(L->next==NULL);
}
int ListLength(LinkList *L)
{
LinkList *p=L;int i=0;
while (p->next!=NULL)
{
i++;
p=p->next;
}
return(i);
}

void DispList(const LinkList *L)
{
LinkList *p=L->next;
while (p!=NULL)
{
printf("%c ",p->data);
p=p->nex