关于用邻接表创建图的问题
程序运行了一会,但什么都没显示{:10_262:}截取了一部分出来。。可以编译。
#include <stdio.h>
#include <stdlib.h>
#define MAXVEX 14
//边表结点
typedef struct EdgeNode
{
int adjvex;
int weight;
struct EdgeNode *next;
} EdgeNode;
//顶点表结点
typedef struct VertexNode
{
int in;
int data;
EdgeNode *firstedge;
} VertexNode,AdjList;
//这个表
typedef struct
{
AdjList adjList;
int numVertexes,numEdges;
} graphAdjList,*GraphAdjList;
void CreateALGraph(GraphAdjList GL)
{
int i;
EdgeNode *e;
GL->numEdges = 20;
GL->numVertexes = 14;
for(i = 0; i < GL->numVertexes; ++i)
{
GL->adjList.data = i;
}
}
int main()
{
GraphAdjList G;
CreateALGraph(&G);
printf("%d",G->numEdges);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define MAXVEX 14
typedef struct Node_of_Edge
{
int adjvex;
int weight;
struct EdgeNode *next;
}EdgeNode;
typedef struct Node_of_Vertex
{
int in;
int data;
EdgeNode *firstedge;
}VertexNode, AdjList;
typedef struct Adjacent_Graph_List
{
AdjList adjList;
int numVertexes, numEdges;
}GraphAdjList;
void CreateALGraph(GraphAdjList ** G)
{
int i;
EdgeNode *e;
*G = (GraphAdjList *)malloc(sizeof(GraphAdjList));
(*G)->numEdges = 20;
(*G)->numVertexes = 14;
for (i = 0; i < (*G)->numVertexes; ++i)
{
(*G)->adjList.data = i;
}
}
int main()
{
GraphAdjList *G;
CreateALGraph(&G);
printf("%d", G->numEdges);
return 0;
}暂时能用 claws0n 发表于 2018-10-12 21:47
暂时能用
Soga..还要申请空间..thx! chinggggg 发表于 2018-10-13 16:34
Soga..还要申请空间..thx!
嗯,因为你原本的 GraphAdjList G 是指针,哪能存储那么多东西?
页:
[1]