푸는 방법이 다양하지만 배열을 이용해서 풀이했다.
public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int[] chess = {1,1,2,2,2,8};
int[] inputC = new int[chess.length];
for(int i = 0; i<inputC.length;i++) {
inputC[i] = sc.nextInt();
System.out.print(chess[i]-inputC[i]);
}
}
}
첫 번째 int[] chess는 원래 가지고 있는 체스로 종류별 1,1,2,2,2,8개가 있다고 했으니 {}안에 직접적으로 적어주었다.
두 번째 입력해야할 int[] inputC에 원래 체스의 갯수만큼 배열 선언을 하고 입력받고 원래 개수에서 입력한 수를 빼면 된다.