hyeals study
[백준 10814] [정렬] [JAVA] 나이순 정렬 본문
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
public class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = 0;
try{
N = Integer.parseInt(br.readLine());
}catch (Exception e){
e.printStackTrace();
}
String[][] arr = new String[N][2];
String[] read = new String[2];
for(int i=0;i<N;i++){
try{
read = br.readLine().split(" ");
}catch (Exception e){
e.printStackTrace();
}
arr[i][0] = read[0];
arr[i][1] = read[1];
}
Arrays.sort(arr, new Comparator<String[]>() {
@Override
public int compare(String[] o1, String[] o2) {
return Integer.parseInt(o1[0]) - Integer.parseInt(o2[0]);
}
});
for(int i=0;i<N;i++){
System.out.println(arr[i][0] + " "+ arr[i][1]);
}
}
}
'백준' 카테고리의 다른 글
[백준 15650] [백트래킹] [JAVA] N과M(2) (0) | 2020.09.08 |
---|---|
[백준 15649] [백트래킹] [JAVA] N과M(1) (0) | 2020.09.08 |
[백준 1436] [브루트포스] [JAVA] 영화감독 숌 (0) | 2020.09.08 |
[백준 2231] [브루트포스] [JAVA] 분해합 (0) | 2020.09.08 |
[백준 2798] [브루트 포스] [JAVA] 블랙잭 (0) | 2020.09.06 |
Comments