-4
異常線程「main」 java.lang.ArrayIndexOutOfBoundsException
for (int i = 0; i < size; i++) { for (int j = i; j < size; j++) {
distances[i][j] = haversin(coords[i][0], coords[j][0], coords[i][1],
coords[j][1]); distances[j][i] = distances[i][j]; } } long start =
System.nanoTime(); int[] shortestPath = nearestNeighbour(distances); double
bestShort = 0; for (int i = 0; i < size; ++i) {bestShort +=
distances[shortestPath[i] - 1][shortestPath[i + 1] - 1]; } bestShort +=
distances[shortestPath[size - 1]][shortestPath[0]];
}
plz發佈代碼不是圖像,仍然與之前的問題相同。沒有改進 –
for(int i = 0; i
sha83
不要將您的代碼置於評論中。把它放在問題上。 – khelwood