题解 | #成绩排名 (20)#

成绩排名 (20)

http://www.nowcoder.com/questionTerminal/3cb0c1b7a4ce442a9e520889fda58275

import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String maxInfo = "";
        String minInfo = "";
        int max = -1;
        int min = 101;
        for(int i = 0 ; i < n ; i++) {
            String name = sc.next();
            String course = sc.next();
            int score = sc.nextInt();
            if(max <= score) {
                max = score;
                maxInfo = name + " " + course;
            }
            if(min >= score) {
                min = score;
                minInfo = name + " " + course;
            }
        }
        System.out.println(maxInfo);
        System.out.println(minInfo);
    }
}
全部评论

相关推荐

05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务