#include<stdio.h>
#include<stdlib.h>
#define MaxSize 100
typedef int ElemType;
typedef struct ArcNode{
int adjvex;
int weight;
struct ArcNode *next;
}ArcNode;
typedef struct VexNode{
ElemType data;
ArcNode * first;
}VexNode,AdjList[MaxSize];
typedef struct {
AdjList vertice;
int vexnum,arcnum;
int kind;
}AlGraph;
int main(){
AlGraph graph;
graph.vexnum = 5;
graph.arcnum = 5;
graph.kind = 1;
for(int index=0;index<graph.vexnum;index++){
graph.vertice[index].data = index+1;
graph.vertice[index].first = NULL;
}
for(int index = 0;index<graph.arcnum;index++){
int src,dest,weight;
scanf("%d %d %d",&src,&dest,&weight);
ArcNode *p = (ArcNode *)malloc(sizeof(ArcNode));
p->adjvex = dest-1;
p->weight = weight;
p->next = graph.vertice[src-1].first;
graph.vertice[src-1].first = p;
}
for(int index = 0;index<graph.vexnum;index++){
int src = graph.vertice[index].data;
ArcNode *p = graph.vertice[index].first;
while(p!=NULL){
/*while写成了if 害我找了半天!!! */
printf("%d %d %d\n",src,(p->adjvex)+1,p->weight);
p = p->next;
}
}
}