본문 바로가기

Java/SWEA

[JAVA] SWEA 1966. 숫자를 정렬하자

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PrmyKAWEDFAUq&categoryId=AV5PrmyKAWEDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=JAVA&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

정답 

 

import java.util.*;

class Solution
{
	public static void main(String args[]) throws Exception
	{	
		Scanner sc = new Scanner(System.in);
		
		int T = sc.nextInt();
		
		for(int t=1; t<=T; t++)
		{
			
			int N = sc.nextInt();
			int num[] = new int[N];
			
			for(int i=0; i<N; i++)
			{
				num[i] = sc.nextInt();
			}
			
			Arrays.sort(num); //오름차순 정렬 
			
			System.out.printf("#%d ",t);
			for(int n : num)
			{
				System.out.print(n+" ");
			}
			System.out.println();
			
		}
		
	}
}