各位大神求助 十字链表存储图的问题
#define maxnode 30#include <stdio.h>
#include <stdlib.h>
typedef struct arc
{
int tailvex;
int headvex;
// int info;
struct arc *hlink;
struct arc *tlink;
}arctype;
typedef struct vertex
{
int data;
struct arctype *firstin;
struct arctype *firstout;
}vertextype;
typedef vertextype graph[maxnode];
int findvertex(int v,graph digraph)
{
int k;
for (k=0;k<maxnode;k++)
{
if (digraph[k].data==v)
return k;
}
}
int main(void)
{
int i,j,n,e,k;
int v1,v2;
arctype *p,*q;
graph digraph;
printf("输入有向图顶点数和边数\n");
scanf("%d%d",&n,&e);
printf("输入顶点数据:\n");
for (k=0;k<n;k++)
{
scanf("%d",&digraph[k].data);
digraph[k].firstin=NULL;
digraph[k].firstout=NULL;
}
printf("输入边的头结点和尾结点:\n");
for (k=0;k<e;k++)
{
scanf("%d%d",&v1,&v2);
p=(arctype*)malloc(sizeof(arctype));
i=findvertex(v1,digraph);
j=findvertex(v2,digraph);
p->tailvex=v1;
p->tlink=digraph[i].firstout;
digraph[i].firstout=p;
p->headvex=v2;
p->hlink=digraph[j].firstin;
digraph[j].firstin=p;
}
printf("有向图的结构为:\n");
for (k=0;k<n;k++)
{
printf("%d.",k+1);
v1=digraph[k].data;
printf("%d",v1);
p=digraph[i].firstout;
while (p=!NULL)
{
v2=p->headvex;
printf("-->%d",v2);
p=p->hlink;
}
printf("\n");
printf("%d.",k+1);
v1=digraph[k].data;
printf("%d",v1);
p=digraph[k].firstin;
while (p=!NULL)
{
v2=p->tailvex;
printf("<--%d",v2);
p=p->tlink;
}
printf("\n");
}
return 0;
}
提醒[Warning] assignment from incompatible pointer type 指针有什么问题吗?求助求助!