题目描述
小乐乐的老师BoBo想知道班级中谁的数学成绩最高,请编程帮他实现。
输入描述
共n+1行
第一行输入一个数n,代表小乐乐的班级中n个同学。
第二行输入n个数,用空格相隔,代表班级中每个人的数学成绩。
输出描述
一个整数,代表班级中最高的数学成绩。
示例1
输入
3
99 89 39
输出
99
代码实现
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int counts = Integer.parseInt(bf.readLine());
String[] strs = bf.readLine().split(" ");
int MaxGrade = Integer.parseInt(strs[0]);
for(int j=0;j<strs.length;j++){
if(MaxGrade<Integer.parseInt(strs[j])){
MaxGrade = Integer.parseInt(strs[j]);
}
}
System.out.println(MaxGrade);
}
}