[java]代码库
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Student stu[] = new Student [3];
int i, j;
for(i = 0;i < 3; i++)
{
int no = scan.nextInt();
String name = scan.next();
int score = scan.nextInt();
stu[i] = new Student(no, name, score);
}
for(i = 0; i < 2; i++)
{
for(j = i+1; j< 3; j++)
{
Student S = new Student(0, "", 0);
if(stu[i].getScore() < stu[j].getScore())
{
S = stu[i];
stu[i] = stu[j];
stu[j] = S;
}
}
}
for(i = 0; i < 3; i++)
{
stu[i].print();
}
scan.close();
}
}
class Student {
private int no;
private String name;
private int score;
public Student(int _no, String _name, int _score) {
no = _no;
name = _name;
score = _score;
}
public int getNo() {return no;}
public String getName() {return name;}
public int getScore() {return score;}
public void print(){
System.out.println(no + " "+name+" "+score);
}
}