有向图的邻接表建立出现问题
#include<stdio.h>#include<stdlib.h>
#define MAX 100
typedef struct
{
int adjvex;
struct EdgeNode *next;
}EdgeNode;
typedef struct
{
char data;
EdgeNode *firstNext;
}VertexNode,AdjList;
typedef struct
{
AdjList adjList;
int numVertexes;
int numArcs;
}GraphAdjList;
int locate(GraphAdjList G,char c)
{
int i=0;
while(G.adjList.data!=c && i<G.numVertexes);
if(i<G.numVertexes)
return i;
else return -1;
}
void CreateAdjList(GraphAdjList *G)
{
int i,j,k;
EdgeNode *p,*q;
char m,n;
printf("请输入顶点和弧的数目\n");
scanf("%d %d",&G->numVertexes,&G->numArcs);
for(k=0;k<G->numVertexes;k++)
{
printf("请输入第%d个顶点的信息\n",k);
scanf("%c",&G->adjList.data);
G->adjList.firstNext=NULL;
}
for(k=0;k<G->numArcs;k++)
{
printf("请按顺序输入弧的弧头v和弧尾w\n");
scanf("%c %c",&m,&n);
q=(EdgeNode *)malloc(sizeof(EdgeNode));
i=locate(G,m);
j=locate(G,n);
q->adjvex=j;
if( G->adjList.firstNext!=NULL )
G->adjList.firstNext=q;
else
{
p=G->adjList.firstNext->next;
while(p)
{
p=p->next;
}
p->next=q;
}
}
}
void print(GraphAdjList *G)
{
int i;
EdgeNode *p;
for(i=0;i<G->numVertexes;i++)
{
printf("%c",G->adjList.data);
p=G->adjList.firstNext;
while(p)
{
printf("->%d",p->adjvex);
p=p->next;
}
printf("->NULL\n");
}
free(p);
}
int main()
{
GraphAdjList *G;
CreateAdjList(G);
print(G);
return 0;
}
Compiling...
fuck.c
D:\×àÃæ\WorkSpace\fuck.c(61) : error C2115: 'function' : incompatible types
D:\×àÃæ\WorkSpace\fuck.c(61) : warning C4024: 'locate' : different types for formal and actual parameter 1
D:\×àÃæ\WorkSpace\fuck.c(62) : error C2115: 'function' : incompatible types
D:\×àÃæ\WorkSpace\fuck.c(62) : warning C4024: 'locate' : different types for formal and actual parameter 1
D:\×àÃæ\WorkSpace\fuck.c(70) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×àÃæ\WorkSpace\fuck.c(73) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×àÃæ\WorkSpace\fuck.c(75) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×àÃæ\WorkSpace\fuck.c(92) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
Error executing cl.exe.
fuck.obj - 2 error(s), 6 warning(s)
好难啊 有没有人帮我啊 我只能一个人默默的哭泣:curse: 似懂非懂所发生的:ton: 可以将破解的结果以文本文档的形式保存在指定目录下。
页:
[1]