求助:应该怎么改。
报错:
main.c:38:12: error: array subscript is not an integer
38 | (*adjlist[a])->FirstNode=p;
| ^
main.c:42:21: error: array subscript is not an integer
42 | p->pNext=(*adjlist[a])->FirstNode;
| ^
main.c:43:12: error: array subscript is not an integer
43 | (*adjlist[a])->FirstNode=p;
| ^
# include<stdio.h>
# include<stdlib.h>
# define MaxVertex 1000
typedef struct AcrNode
{
int adjvex;
struct AcrNode *pNext;
int info;
}AcrNode,*pAcrNode;
typedef struct Vertex
{
int data;
AcrNode * FirstNode;
}Vertex,Adjlist[MaxVertex];
void CreateVertexlist(Vertex*a)
{
int i,n,k,b,j;
Adjlist *adjlist=NULL;
AcrNode*p;
printf("输入总共有几个顶点几条边");
scanf("%d %d",&n,&k);
for(i=0;i<n;i++)
{
printf("输入第%d个节点的信息:",i);
scanf("%d",adjlist[i]->data);
adjlist[i]->FirstNode=NULL;
}
for(j=0;j<k;k++)
{
scanf("%d %d",&a,&b);
p=(AcrNode*)malloc(sizeof(AcrNode));
p->adjvex=b;
/*p->pNext=(*adjlist[a])->FirstNode;*/
(*adjlist[a])->FirstNode=p;
p=(AcrNode*)malloc(sizeof(AcrNode));
p->adjvex=b;
p->pNext=(*adjlist[a])->FirstNode;
(*adjlist[a])->FirstNode=p;
}
}
|