The computer is giving segmentation fault whenever I try to read input into this. My input looks like:
7
1 2 3
2 3 1
1 4 4
4 6 7
7 5 2
3 5 1
4 5 5
Basically, I want to store the above input directly into a 2D array. The first column is X-coordinates, 2nd column Y-coordinate and finally the value needed to store in (X,Y) COORDINATE of a 2D array.
long leastTimeToInterview(int n, int k, int m) {
int a[m+1][m+1];
int i=0,x=0,y=0;
for (i=1;i<=m;i++){
scanf("%d %d",&x,&y);
scanf("%d",&a[x][y]);
a[y][x]=a[x][y];
}
return 11;
}