문제풀이 19번

박천규·2020년 12월 29일
0

자바 기초문제풀이

목록 보기
19/30

1~100까지 숫자가 입력될 때 한번이라도 입력되었으면 출력하시오.

입력 : 1 2 3 1 1 2 3 4 5 5

정답: 1 2 3 4 5

package _2;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		for(int i=0 ; i<6 ; i++) {
			int a= sc.nextInt();
			if(number.contains(a)) {
				continue;
			}
			else {
				number.add(a);
			}
		}
		Collections.sort(number);
		for( int a : number) 		
		System.out.print(a+" ");
		
		
		
				
			
			
		
		 
	}
}
profile
자바 공부중

0개의 댓글

관련 채용 정보