我有一個多維數組,其中包含字符串值的行和列包含整數值。我想找到這在列這種情況下,最大比分的最大值如何在多維數組中找到最大值
這裏是我到目前爲止的代碼(JAVA)
public class HighScore {
int row;
int col;
Scanner input = new Scanner(System.in);
public void maxscore() {
System.out.println("How many students are you entering scores for");
int st_num = input.nextInt();
String[][] arr = new String[st_num][1];
for (row = 0; row < arr.length; row++) {
System.out.println("Please enter the student's name");
String name = input.next();
for (col = 0; col < arr[row].length; col++) {
System.out.println("Please enter the students's score");
int score = input.nextInt();
}
}
System.out.println("Highest score entered was");
}
public static void main(String[] args) {
HighScore obj = new HighScore();
obj.maxscore();
}
}
所以,嗯如果u有任何建議或答案,請幫助
比方說,我請你告訴我,最多的是什麼表{5,3,2,4,1,9}。你會如何一步步確定這一點? – Compass
嗯我不知道? –
@KarryAlams你必須做String [st_num] [2]; 2而不是1,因爲索引從0開始,但在初始化數組時,必須從1輸入數值而不是從0輸入數值。然後請參閱這個http://stackoverflow.com/questions/38191408/how-to-sort-multidimensional-string-array-by-column-in-integer-value-in-java問題。我有和你一樣的問題,並得到回答。 – creativecreatorormaybenot