문제
링크
테스트 케이스가 50보다 작아서 버블정렬을 사용해도 되지만 그냥 Arrays.sort() 사용해서 풀었다.
수도코드]
T(테스트 케이스 수)
for(tc : 1 ~ T){
N(해당 테스트 케이스의 숫자 개수)
A[N] 선언
for( i : 0 ~ N ) {
A[]에 숫자 넣어주기
}
A[] 정렬
for( k : 0 ~ N ) {
A[] 출력
}
import java.util.*;
import java.io.*;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
int N = sc.nextInt();
int[] A = new int[N];
System.out.print("#" + test_case + " ");
for (int i = 0; i < N; i++ ) {
A[i] = sc.nextInt();
}
Arrays.sort(A);
for (int k = 0; k < N; k++) {
System.out.print(A[k] + " ");
}
System.out.println();
}
}