请问错在哪?
#include<stdio.h>#include<stdlib.h>
typedef struct enode
{int adjv;
struct enode*next;
}ENode;
typedef struct vnode
{char ch;
ENode*first;
}VNode;
ENode*stalist(int num)
{ENode *p,*p1,*p2;
int i,k;
for(i=1;i<=num;i++)
{scanf("%d",&k);
p2=(ENode*)malloc(sizeof(ENode));
p2->adjv=k;
p2->next=NULL;
if(i==1){p=p2;p1=p;continue;}
p1->next=p2;
p1=p2;
}
return p;
}
void outlist(VNode adjlist[])
{VNode*p1,*p2;
ENode*pe1;
int i;
for(i=0,p1=adjlist;i<7;i++,p1++)
{printf("%c:\n",p1->ch);
pe1=p1->first;
while(pe1)
{p2=adjlist+pe1->adjv;
printf("(%c-%c)",p1->ch,p2->ch);
pe1=pe1->next;
}
printf("\n");
}
printf("\n");
}
void dfs(VNode adjlist[],int visit[],ENode *parray[],int i)
{int d;
if(visit[i]==0)
{printf("(%c)",adjlist[i].ch);
visit[i]=1;
}
while(parray[i])
{d=parray[i]->adjv;
if(visit[d]==0)dfs(adjlist,visit,parray,d);
parray[i]=parray[i]->next;
}
void bfs(VNode adjlist[],int visit[],ENode *parray[],int i)
{int d,front=0,rear=0,queue[20];
queue[rear]=i;
rear++;
while(front!=rear)
{d=queue[front];
front++;
if(visit[d]==0)
{printf("(%c)",adjlist[d].ch);
visit[d]=1;
while(parray[d])
{queue[rear++]=parray[d]->adjv;
parray[d]=parray[d]->next;
}
}
}
}
void main()
{VNode adjlist[7];
ENode*p1,*parray[7];
static int visit[7];
char c='A';
int i,num;
for(i=0;i<7;i++,c++)
{adjlist[i].ch=c;
adjlist[i].first=NULL;
printf("Input Degree of %c\n",c);
scanf("%d",&num);
if(num>0)adjlist[i].first=stalist(num);
parray[i]=adjlist[i].first;
}
outlist(adjlist);
printf("dfs:");
for(i=0;i<7;i++)
dfs(adjlist,visit,parray,i);
printf("\n");
for(i=0;i<7;parray[i]=adjlist[i].first,visit[i++]=0);
printf("bfs:");
for(i=0;i<7;i++)
bfs(adjlist,visit,parray,i);
printf("\n");
}