你好你大哥就似我,你用一个数组 dist 记录最短路径长,用另一个数组 pre 记录直接前驱。关键语句如下:if (dist[j] > dist[i] + edge[i, j]){ dist[j] = dist[i] + edge[i, j]; pre[j] = i;}这样就行了。