hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #나머지 #275

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];
    int[] arr2 = new int[10];

    int count = 0;
    for(int i=0; i<10; i++) {
        arr[count++] = scanner.nextInt() % 42 ;
    }

    for(int i=0; i<arr.length-1; i++) {
        int empty = 0;
        for(int j=i+1; j<arr.length; j++){
            if (arr[i] > arr[j]) {
                empty = arr[i];
                arr[i] = arr[j];
                arr[j] = empty;
            }
        }
    }

    int x= 1;

    for(int i=0 ;i<arr.length-1; i++){
        if (arr[i] != arr[i+1]) {
            x++;
        }
    }

    System.out.println(x);

}

}