Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 코테
- 코딩테스트
- Tree
- Class
- Binary Search
- database
- Matrix
- Stack
- sorting
- two pointers
- SQL
- greedy
- Counting
- array
- 자바
- dynamic programming
- Math
- java
- hash table
- implement
- geometry
- Method
- Binary Tree
- 구현
- Data Structure
- simulation
- bit manipulation
- Number Theory
- string
- 파이썬
Archives
- Today
- Total
코린이의 소소한 공부노트
[백준 온라인 저지] 2752. 세수정렬 본문
1. 입력
- 숫자 세 개가 주어진다. 이 숫자는 1보다 크거나 같고, 1,000,000보다 작거나 같다. 이 숫자는 모두 다르다.
2. 출력
- 제일 작은 수, 그 다음 수, 제일 큰 수를 차례대로 출력한다.
3. 예제
4. 코드
import java.util.*;
class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int[] num = new int[3];
for(int i=0 ; i<3 ; i++)
num[i] = scan.nextInt();
for(int i=0 ; i<2 ; i++){
int j = i;
while(j>=0 && num[j]>num[j+1]){
int tmp = num[j];
num[j] = num[j+1];
num[j+1] = tmp;
j--;
}
}
for(int i=0 ; i<3 ; i++)
System.out.print(num[i]+" ");
}
}
- 삽입 정렬 이용
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 530. Minimum Absolute Difference in BST (0) | 2023.05.23 |
---|---|
[LeetCode/Easy] 506. Relative Ranks (0) | 2023.05.23 |
[LeetCode/Easy] 485. Max Consecutive Ones (0) | 2023.05.19 |
[LeetCode/Easy] 482. License Key Formatting (0) | 2023.05.19 |
[LeetCode/Easy] 459. Repeated Substring Pattern (0) | 2023.05.19 |