코딩테스트준비

[백준2750]수 정렬하기

예쁜꽃이피었으면 2024. 1. 25. 09:18

https://www.acmicpc.net/problem/2750

 

2750번: 수 정렬하기

첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 절댓값이 1,000보다 작거나 같은 정수이다. 수는 중복되지 않는다.

www.acmicpc.net

 

* 백준 문제풀 때 이클립스나 다른 에디터 열여서 문제 풀고 백준 > 제출 탭 눌러서 코드 복붙하면 된다.

* class이름은 Main .. 이렇게 안바꾸면 컴파일 에러남.

 

 

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int tc = sc.nextInt();
		int[] testArr = new int[tc];
		
		for(int i=0; i < tc; i++) {
			int tempint = sc.nextInt();
			testArr[i] = tempint;
		}
		
		Arrays.sort(testArr);
//		System.out.println(Arrays.toString(testArr));
		
		for(int i=0; i < testArr.length; i++) {
			System.out.println(testArr[i]);
		}
		
		
		
	}

}

 

반응형

'코딩테스트준비' 카테고리의 다른 글

[백준1546]평균 구하기  (0) 2024.01.25
[백준11720]숫자의 합 구하기  (0) 2024.01.25
백준 9012 자바  (0) 2020.09.19
백준 10828 자바  (0) 2020.09.19
백준 9093 자바  (0) 2020.09.19