I want to read from a file test.txt with the contents
Legend:
ABCD
DistanceMatrix:
0
10 0
11 12 0
13 14 15 0
My idea is to first pass all values in the distance matrix into a temp[] array, thus temp will contain [0 10 0 11 12 0 13 14 15 0]
Then, i want to pass these values in temp into another multidimensional array distanceMatrix[][].
Here is the code
The idea is to increment y after a value of 0.0 has been passed into distanceMatrix, to create the result ofCode:int x=0; for(int i=0;i<size;i++){ int y=0; distanceTable[x][y]=temp[i]; if(distanceTable[x][y]==0.0) x++; else y++; }
However, with my code, the result i get with my distanceMatrix array are all zeros. What is the problem?Code:distanceMatrix[0][0]=0.0 distanceMatrix[0][1]=0.0 distanceMatrix[0][2]=0.0 distanceMatrix[0][3]=0.0 distanceMatrix[1][0]=10.0 distanceMatrix[1][1]=0.0 distanceMatrix[1][2]=0.0 distanceMatrix[1][3]=0.0 distanceMatrix[2][0]=11.0 distanceMatrix[2][1]=12.0 distanceMatrix[2][2]=0.0 distanceMatrix[2][3]=0.0 distanceMatrix[3][0]=13.0 distanceMatrix[3][1]=14.0 distanceMatrix[3][2]=15.0 distanceMatrix[3][3]=0.0


Reply With Quote


Bookmarks