백준 #31609번 現れている数字 (Appearing Numbers)

jhj·2024년 12월 31일

백준 JAVA

목록 보기
527/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] check = new int[10];
		
		for(int i = 0; i < 10; i++) {
			check[i] = 0;
		}
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 10; j++) {
				if(a[i] == j) {
					check[j] = 1;
					break;
				}
			}
		}
		
		for(int i = 0; i < 10; i++) {
			if(check[i] == 1) {
				System.out.println(i);
			}
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글