include stdio include stdlib typedef struct pNode struct pNode next in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<stdio.h>
#include<stdlib.h>
typedef struct pNode {
struct pNode *next;
int edgeWeight;
} Node;
Node *list[100];
void addEdge(int i, int j, int k)
{
Node *newNode;
newNode = malloc(sizeof(Node));
newNode->next = list[i];
newNode->edgeWeight = k;
list[i] = newNode;
}
int main()
{
int n,i,j;
scanf("%d%d",&n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
int k;
scanf("%d",&k);
if(k) addEdge(i,j,k);
}
return 0;
}