hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #중복 수 제거 #271

Open hwangnk1004 opened 4 years ago

hwangnk1004 commented 4 years ago

import java.util.Scanner;

public class Main { public static void main(String args[]) {

    Scanner scanner = new Scanner(System.in);

    int[] arr = new int[10];

    for (int i = 0; i < arr.length; i++) {
        arr[i] = scanner.nextInt();
    }

    int kk = 0;

    for (int i = 0; i < arr.length - 1; i++) {
        int count = 0;

        for (int j = i + 1; j < arr.length; j++) {

            if (arr[i] == arr[j]) {
                count++;
                arr[j] = 11;
            }

        }

        if (count > 0) {
            arr[i] = 11;
        }
    }

    for (int i = 0; i < arr.length; i++) {
        if (arr[i] < 11) {
            System.out.print(arr[i] + " ");
        }
    }

}

}