欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

洛谷——排队接水

时间:2023-08-10

题目链接:排队接水

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

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。