Home > Back-end >  MOOC homework help thank you bosses
MOOC homework help thank you bosses

Time:01-08

 import Java. Util. ArrayList; 
import java.util.Scanner;

Public class Main {
Public static void main (String [] args) {
Scanner in=new Scanner (System. In);//first line
ArrayList Datas=new ArrayList<> (a);
int i=0;
While (true) {
Datas. The add (in the next ());
i++;
If (datas. Get (I - 1). The equals (" # # # ")) {
Datas. Remove (I - 1);
Finished System. Out. Println (" input ");
break;
}
}//record finish
i--;

The Input String []=new String [I];
Scanner Scanner=new Scanner (System. In);
For (int j=0; J & lt;=i; J++) {
Input [j]=scanner. NextLine ();
}
Dist=new String String [] [] [I] [I];
For (int j=0; J & lt;=i; J++) {
Dist [j]=Input [j]. The split (" \ \ s + ");
}

for(int j=0; j<=I; J++) {
For (int k=0; k<=I; K++) {
System. The out. Print (dist [j] [k]);
}
System. The out. Print ("/n ");
}
}

}


"C: \ Program Files \ Java \ JDK - 15.0.1 \ bin \ Java. Exe" "- javaagent: F: \ IntelliJ IDEA Educational Edition 2020.2.3 \ lib \ idea_rt jar=54260: F: \ IntelliJ IDEA Educational Edition 2020.2.3 \ bin" - Dfile. Encoding=utf-8 - classpath C: \ Users \ Nayami \ IdeaProjects \ Week3 \ out \ production \ Week3 Main
Hagzou Hugzou Jigxng # # #
Entry is
0 1108 708

1108 0, 994

708, 994, the exception in the thread "is the main" Java. Lang. ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
At the Main. The Main (Main. Java: 23)

The Process finished with exit code 1
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Could you tell me how to solve this bug, thanks for your bosses
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Title:
Below for the domestic highway mileage between major cities:







A list of your program to read this, then, according to input the name of the two cities, given the range between the two cities,



Note: the mileage between any two cities have been given, do not need to calculate the third transit,

Note: you don't need to input the above data, the data is input to the program,



Input format:

First of all, you will read a number of the name of the city, every name is just a word of English, do not contain Spaces or other symbols, middle when read the name of "# # #" (# 3), said the city name input end, # # # is not the name of a city, if read remember city name for the number of n,

Then, you will read an integer of NXN matrix, the first line of each number, said the city list first city to another city in turn between the mileage, table in the same city mileage between 0,

In the end, you will read the name of the two cities,



The output format:

The output of the distance between the two cities,



Input the sample:

Hagzou Hugzou Jigxng # # #

0 1108 708

1108 0, 994

708, 994,

Hagzou Jigxng



The output sample:

708


  • Related