hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #일곱난장이 #258

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[9];
    int sum =0;
    for(int i = 0; i<arr.length; i++) {
        arr[i] =scanner.nextInt();
        sum +=arr[i];
    }
    int no = sum-100;

    int[] lie = new int[2];
    hwang:
    for(int i=0 ; i<arr.length-1; i++) {
        for(int j=i+1; j<arr.length; j++) {
            if (arr[i]+ arr[j] == no) {
                lie[0] = arr[i];
                lie[1] = arr[j];
                break hwang;
            }
        }
    }

    for(int i =0; i<arr.length; i++) {
        if (arr[i] != lie[0] && arr[i] !=lie[1]) {
            System.out.println(arr[i]);
        }
    }

}

}