代码拉取完成,页面将自动刷新
import java.util.List;
import java.util.Scanner;
public class Mainlihaoyanzazhong {
public final static int N = Integer.MAX_VALUE;
public static void SHOW() {
FloydInGraph graph = new FloydInGraph(10);
int[][] matrix = {
{0, N, 40, 80, N, N, N, N, N, N},
{N, 0, N, 70, 60, N, 20, 20, N, N},
{40, N, 0, N, 20, 80, N, N, N, N},
{80, 70, N, 0, 90, N, N, N, N, N},
{N, 60, 20, 20, 0, N, N, N, N, N},
{N, N, 80, N, N, 0, 40, N, 10, N},
{N, 20, N, N, N, 40, 0, 50, N, N},
{N, 20, N, N, N, N,50, 0, 60, 90},
{N, N, N, N, N, 10, N, 60, 0, 70},
{N, N, N, N, N, N, N, 90, 70, 0}};
Scanner sc = new Scanner(System.in);
int begin = 0;
int end = 0;
int s = 1;
String x, y;
System.out.println("有以下城市:A,B,C,D,E,F,G,H,I,J");
System.out.println("请输入电信抢修队所在城市的位置:");
x = sc.next();
switch (x) {
case "A":
begin = 0;
break;
case "B":
begin = 1;
break;
case "C":
begin = 2;
break;
case "D":
begin = 3;
break;
case "E":
begin = 4;
break;
case "F":
begin = 5;
break;
case "G":
begin = 6;
break;
case "H":
begin = 7;
break;
case "I":
begin = 8;
break;
case "J":
begin = 9;
break;
default:
System.out.println("没有这个城市或城市名称错误,请重新进入系统");
return;
}
System.out.println("请输入维护现场所在城市的位置:");
y = sc.next();
switch (y) {
case "A":
end = 0;
break;
case "B":
end = 1;
break;
case "C":
end = 2;
break;
case "D":
end = 3;
break;
case "E":
end = 4;
break;
case "F":
end = 5;
break;
case "G":
end = 6;
break;
case "H":
end = 7;
break;
case "I":
end = 8;
break;
case "J":
end = 9;
break;
default:
System.out.println("没有这个城市或城市名称错误,请重新进入系统");
return;
}
graph.findCheapestPath(begin, end, matrix);
List<Integer> list = graph.result;
System.out.print(String.valueOf(begin).replace("0", "A").replace("1", "B")
.replace("2", "C").replace("3", "D").replace("4", "E")
.replace("5", "F").replace("6", "G").replace("7", "H")
.replace("8", "I").replace("9", "J")
+ "城市 到 " + String.valueOf(end).replace("0", "A").replace("1", "B")
.replace("2", "C").replace("3", "D").replace("4", "E")
.replace("5", "F").replace("6", "G").replace("7", "H")
.replace("8", "I").replace("9", "J") + "城市,最短距离为:");
System.out.println(graph.dist[begin][end] + " km");
System.out.println(list.toString().replace("0", "A").replace("1", "B")
.replace("2", "C").replace("3", "D").replace("4", "E")
.replace("5", "F").replace("6", "G").replace("7", "H")
.replace("8", "I").replace("9", "J"));
System.out.println("---------------------------------------------------");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。