-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path2752.java
More file actions
34 lines (29 loc) · 810 Bytes
/
Copy path2752.java
File metadata and controls
34 lines (29 loc) · 810 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
31
32
33
34
// Copyright@2023 Jihoon Lucas Kim <jihoon.lucas.kim@gmail.com>
//세수정렬
//https://www.acmicpc.net/problem/2752
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n1 = sc.nextInt();
int n2 = sc.nextInt();
int n3 = sc.nextInt();
int arr[] = {n1, n2, n3};
// 방법 1. 3가지 수만 정렬하면 되므로 비교해서 작은값부터 정렬하는 기법 사용.
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
// 방법 2.
// Arrays.sort(arr);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
}