4 Star 0 Fork 0

李小蒙/project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
第五个功能(部分) 4.09 KB
一键复制 编辑 原始数据 按行查看 历史
刘锐 提交于 2021-12-21 08:02 . add 第五个功能(部分).
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("---------------------------------------------------");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li-xiaomeng_01/project.git
git@gitee.com:li-xiaomeng_01/project.git
li-xiaomeng_01
project
project
master

搜索帮助