반응형
import java.util.Scanner;
public class Main {
static class Instruction{
int num;
int gas;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int cnt = sc.nextInt();
Instruction[] insts = new Instruction[cnt];
for(int i = 0; i < cnt; i++){
Instruction inst = new Instruction();
inst.num = sc.nextInt();
inst.gas = sc.nextInt();
insts[i] = inst;
}
for(int i = 0; i < cnt; i++){
for(int j = i; j < cnt; j++){
if(insts[i].num > insts[j].num){
Instruction temp = insts[i];
insts[i] = insts[j];
insts[j] = temp;
}
}
}
for(int i = 0; i < cnt; i++) {
System.out.printf("%d %d\n", insts[i].num, insts[i].gas);
}
}
}
반응형
'프로그래밍 > 코드업 일기' 카테고리의 다른 글
코드업(Codeup) 2634 : 거스름돈 II (0) | 2023.08.10 |
---|---|
코드업(Codeup) 2631 : 보물 찾기 (0) | 2023.08.10 |
코드업(Codeup) 2628 : 케익 자르기 (0) | 2023.08.10 |
코드업(Codeup) 1920 : (재귀함수) 2진수 변환 (0) | 2023.08.10 |
코드업(Codeup) 1916 : (재귀함수) 피보나치 수열 (Large) (0) | 2023.08.10 |