ZZULIOJ 1180: 成绩统计(结构体专题),Java

1180: 成绩统计(结构体专题)

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;
class student
{
    String num,name;
    int x,y,z;
}
public class Main {
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static Scanner cin = new Scanner(System.in);
    static student []a = new student[110];
    public static void main(String[] args) {
        int n=cin.nextInt();
        for(int i=0;i<=n;i++) a[i]=new student();
        for(int i=1;i<=n;i++)
        {
            a[i].num=cin.next();
            a[i].name=cin.next();
            a[i].x=cin.nextInt();
            a[i].y=cin.nextInt();
            a[i].z=cin.nextInt();
        }
        student maxn=a[1];
        for(int i=1;i<=n;i++)
            if(a[i].x+a[i].y+a[i].z>maxn.x+maxn.y+maxn.z)
                maxn=a[i];
        out.println(maxn.num+" "+maxn.name+" "+maxn.x+" "+maxn.y+" "+maxn.z);
        out.flush();
    }
}

你可能感兴趣的:(#,Java刷题,java)