题目链接:排队接水
java代码:
import java.util.Arrays; import java.util.Scanner; class People implements Comparable{ int id; int time; public People(int id, int time) { super(); this.id = id; this.time = time; } // 升序排列 public int compareTo(People newPeople) { return Integer.compare(this.time, newPeople.time); } } public class Main { public static void main(String[] args) { int n; Scanner in = new Scanner(System.in); n = in.nextInt(); // 初始化对象数组并排序 People arr[] = new People[n]; for(int i=0;i 欢迎分享,转载请注明来源:内存溢出
评论列表(0条)