求解 线性表编译出错
#include <stdio.h>#include <stdlib.h>
#define MaxCol 10
void CreateTable(HList *&h);
void DestroyTable(HList *h);
void DispTable(HList *h);
void LinkTable(HList *h1,HList *h2,HLIst *&h);
typedef struct Nodel
{
ElemType data[MaxCol];
struct Nodel *next;
}DList;
typedef struct Node2
{
int Row,Col;
DList *next;
}HList;
typedef int ElemType;
void main()
{
HList *h1, *h2, *h;
printf("±í1:\n");
CreateTable(h1);
printf("±í2:\n");
CreateTable(h2);
LinkTable(h1,h2,h);
printf("Á¬½Ó½á¹û±í£º\n");
DispTable(h);
DestroyTable(h1);
DestroyTable(h2);
DestroyTable(h);
}
void CreateTable(HList *&h)
{
int i,j;
DList *r, *s;
h = (HList *)malloc(sizeof(HList));
printf("±íµÄÐÐÊý£¬ÁÐÊý£º");
scanf("%d,%d",&h->Row,&h->Col);
for(i=0;i<h->Row;i++)
{
printf("µÚ%dÐУº",i+1);
s = (DList *)malloc(sizeof(DList));
for(j=0;j<h->Col;j++)
scanf("%d,",&s->data[j]);
if (h->next == NULL)
h->next = s;
else
r->next = s;
r=s;
}
r->next = NULL;
}
void DestroyTable(HList *h)
{
DList *pre = h->next, *p = pre->next;
while(p!=NULL)
{
free(pre);
pre = p;
p = p->next;
}
free(pre);
free(h);
}
void DispTable(HList *h)
{
int j;
DList *p = h->next;
while(p!=NULL)
{
for(j=0;j<h-.Col;j++)
printf("%4d",p->data[j]);
printf("\n");
p = p->next;
}
}
void LinkTable(HList *h1,HList *h2,HLIst *&h)
{
int i,j,k;
DList *p = h->next,*q, *s, *r;
printf("Á¬½Ó×Ö¶ÎÊÇ£ºµÚ1¸ö±íÐòºÅ£¬µÚ2¸ö±íÐòºÅ£º");
scanf("%d,%d",&i,&j);
h = (HList *)malloc(sizeof(HList));
h->Row = 0;
h->Col = h1->col+h2->Col;
h->next = NULL;
while(p!=NULL)
{
q=h2->next;
while(q!=NULL)
{
if(p->data[i-1] == q->data[j-1])
{
s = (DList *)malloc(sizeof(DList));
for(k=0;k<h1->Col;k++)
s->data[k] =p->data[k];
for(k=0;k<h2->Col;k++)
s->data[h1->Col+k] = q->data[k];
if (h->next == NULL)
h->next = s;
else
r->next = s;
r=s;
h->Row++;
}
q = q->next;
}
p = p->next;
}
r->next = NULL;
}