| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 리뷰
- 자바스크립트
- nodejs
- boot
- 인터페이스
- 자바
- Spring
- javascript
- 백준
- effective
- elasticsearch
- 후기
- 알고리즘
- RCP
- 스프링
- Git
- jface
- java8
- error
- kibana
- MySQL
- java
- Web
- Spring Boot
- 독후감
- 이펙티브
- node
- JPA
- 맛집
- 엘라스틱서치
Archives
- Today
- Total
wedul
선택정렬, 버블정렬, 삽입정렬 예제 본문
반응형
선택정렬
for(int i = 0; i<money.length ;i++){
min = i;
for(int j=i;j<money.length;j++){
if(money[j]<money[min])
min=j;
}
temp=money[i];
money[i] = money[min];
money[min]=temp;
}
버블정렬
for(int i = money.length; i>0; i--){
for(int j=0;j<i-1;j++){
if(money[j]>money[j+1]){
temp=money[j];
money[j]=money[j+1];
money[j+1]=temp;
}
}
}
삽입정렬
for(int i=0;i<money.length;i++){
for(int j=0;j<=i;j++)
{
if(money[i]<money[j]){
temp=money[i];
for(int k=i;k>j;k--)
{
money[k] = money[k-1];
}
money[j]=temp;
break;
}
}
}
반응형
'JAVA > 알고리즘' 카테고리의 다른 글
| 정렬알고리즘 - 선택정렬 (0) | 2018.05.28 |
|---|---|
| 10진수 2진수 변환 (0) | 2018.05.28 |
| 더블링크드 리스트 구현하기 (0) | 2018.05.28 |
| 백준 1924 - 요일 맞추기 (0) | 2018.05.28 |
| 백준 2839 - 설탕 배달 (0) | 2018.05.28 |
