Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Map.Entry;
- import java.util.NavigableMap;
- import java.util.Scanner;
- import java.util.TreeMap;
- import java.util.TreeSet;
- public class TemperatureSorter {
- public static void main(String[] args) {
- Scanner in = null;
- try {
- in = new Scanner(new File("kion.txt"));
- }
- catch (Exception e) {
- }
- NavigableMap<Double, TreeSet<Integer>> temperature =
- new TreeMap<Double, TreeSet<Integer>>();
- int day = 0;
- while (in.hasNextLine()) {
- double temp = .0;
- try {
- temp = new Double(in.nextLine());
- }
- catch (Exception e) {
- }
- if (temperature.get(temp) == null) temperature.put(temp, new TreeSet<Integer>());
- temperature.get(temp).add(++day);
- }
- Entry<Double, TreeSet<Integer>> e = temperature.firstEntry();
- for (int i: e.getValue()) {
- System.out.println("" + i + "日: " + e.getKey());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement