- Notifications
You must be signed in to change notification settings - Fork 846
/
Copy path1.java
28 lines (22 loc) · 667 Bytes
/
1.java
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
importjava.util.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
intn = 10;
int[] arr = {7, 5, 9, 0, 3, 1, 6, 2, 4, 8};
for (inti = 0; i < n; i++) {
intmin_index = i; // 가장 작은 원소의 인덱스
for (intj = i + 1; j < n; j++) {
if (arr[min_index] > arr[j]) {
min_index = j;
}
}
// 스와프
inttemp = arr[i];
arr[i] = arr[min_index];
arr[min_index] = temp;
}
for(inti = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
}
}