Skip to content

Commit 76b5bee

Browse files
authored
Create note.md
1 parent e19b93b commit 76b5bee

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

선택정렬/note.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```bash
2+
package algo;
3+
4+
5+
import java.lang.reflect.Array;
6+
7+
/**
8+
* 1 10 5 8 7 6 4 3 2 9
9+
* 가장 작은 놈을 선택해서 앞으로 보내는
10+
* 선택 정렬
11+
* O(n^2)
12+
* */
13+
public class Main {
14+
public static void main(String[] args) {
15+
int[] ints = {1, 10, 5, 8, 7, 6, 4, 3, 2, 9};
16+
int index = -1;
17+
for (int i = 0; i < 10; i++) {
18+
int min = 999;
19+
for (int j = i; j < 10; j++) {
20+
if (min > ints[j]) {
21+
min = ints[j];
22+
index = j;
23+
}
24+
}
25+
int temp = ints[i];
26+
ints[i] = min;
27+
ints[index] = temp;
28+
}
29+
for (int anInt : ints) {
30+
System.out.println(anInt);
31+
}
32+
33+
}
34+
}
35+
36+
```

0 commit comments

Comments
 (0)