-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTripleSort.java
More file actions
30 lines (30 loc) · 785 Bytes
/
TripleSort.java
File metadata and controls
30 lines (30 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Arrays;
import java.util.Scanner;
class Data implements Comparable<Data>{
int x;
double y;
String s;
public Data(int x, double y, String s){
this.x = x;
this.y = y;
this.s = s;
}
public int compareTo(Data t){
/**x<t, return x */
return x-t.x;
}
}
public class TripleSort {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Data[] datas = new Data[n];
for (int i = 0; i < n; i++){
datas[i] = new Data(sc.nextInt(), sc.nextDouble(), sc.next());
}
Arrays.sort(datas);
for (Data data: datas){
System.out.printf("%d %.2f %s\n"), data.x, data.y, data.s);
}
}
}