문자열 값이 포함 된 행과 정수 값을 포함하는 행이있는 다차원 배열이 있습니다. 나는다차원 배열에서 최대 값을 찾으려면 어떻게합니까
여기하는 u는 어떤 제안 또는 답변이 경우
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();
}
}
그래서 음
도와주세요 (JAVA) 지금까지 내 코드 열에이 경우 최대 점수의 최대 값을 찾으려면
의 내가 가장 높은 번호가 목록에 무엇을 말해하도록 요청한다고 가정 해 봅시다 {5, 3, 2, 4, 1, 9}. 단계별로 어떻게 결정합니까? – Compass
음 I dunno ????? –
@KarryAlams 당신은 문자열 [st_num] [2]; 인덱스가 0부터 시작하기 때문에 1 대신 2를 사용하지만 배열을 초기화 할 때는 0이 아닌 1부터 숫자 값을 입력해야합니다. 그런 다음 http://stackoverflow.com/questions/38191408/how-to-sort-multidimensional-string-array-by-one-column-in-integer-value-in-java 질문을 참조하십시오. 나는 당신이 가진 것과 똑같은 질문을했고 대답했습니다. – creativecreatorormaybenot