dev.Log
2750 버블정렬 본문
package acmicpc;
import java.util.Scanner;
public class P2750_버블정렬 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int[] A = new int[N];
for(int i=0; i<N; i++) {
A[i] = scan.nextInt();
}
for(int i=0; i<N-1; i++) {
for(int j=0; j<N-1-i; j++) {
if(A[j] > A[j+1]) {
int temp = A[j];
A[j] = A[j+1];
A[j+1] = temp;
}
}
} //for
for(int i=0; i<N; i++) {
System.out.println(A[i]);
}
}
}
'알고리즘' 카테고리의 다른 글
11286 우선순위큐에 우선순위 적용하기 (0) | 2022.09.13 |
---|---|
2164 큐 (0) | 2022.09.13 |
17298 스택 (0) | 2022.09.13 |
스택 P1874 (0) | 2022.09.12 |
Deque<Node> deque = new LinkedList<>(); (0) | 2022.09.12 |
Comments