c 的拓扑,通过不了,出了点小问题。

来源:百度知道 编辑:UC知道 时间:2024/05/21 04:03:24
#define NULL 0
#define maxvex 100
typedef char vertextype[];
typedef struct edgenode
{ int adjvex ;
int value;
struct edgenode *next;
}arcnode;
typedef struct vexnode
{ vertextype data;
int count;
arcnode *firstarc;
}vheadnode;
typedef struct
{ int n,e;
vheadnode adjlist[maxvex];
}Adjlist;
int createadjlist(Adjlist *g)
{ int i,b,t,w;
arcnode *p;
printf("\nding de sun bian sun");
scanf("%d%d",&g->n,&g->e);
for(i=0;i<g->n;i++)
{ scanf("%s",g->adjlist[i].data);
g->adjlist[i].firstarc=NULL;
g->adjlist[i].count=0;
}
for(i=0;i<g->e;i++)
{ printf("\n qi dian, zhong dian, qun zhi") ;
scanf("%d%d%d",&b,&t,&w);
if(b<g->n && t<g->n && w>0)
{ p=(arcnode *)malloc(sizeof(

你的代码有很多问题, 我帮你把它搞的能编译通过了,但是这个程序是干什么的我不清楚,你原来代码中是否有逻辑错误我也不清楚了。

#include <stdio.h>
#include <stdlib.h>

#define maxvex 100
typedef char vertextype[200];

typedef struct edgenode
{
int adjvex ;
int value;
struct edgenode *next;
}arcnode;

typedef struct vexnode
{
vertextype data;
int count;
arcnode *firstarc;
}vheadnode;

typedef struct
{
int n,e;
vheadnode adjlist[maxvex];
}Adjlist;

int createadjlist(Adjlist *g)
{
int i,b,t,w;
arcnode *p;
printf("\nding de sun bian sun");
scanf("%d%d",&g->n,&g->e);
for(i=0;i<g->n;i++)
{
scanf("%s",g->adjlist[i].data);
g->adjlist[i].firstarc=NULL;
g->adjlist[i].count=0;
}
for(i=0;i<g->e;i++)