3003번: 킹, 퀸, 룩, 비숍, 나이트, 폰
- 본문에 나와 있듯이 각 체스말들의 개수는 고정되어있고, 입력으로는 현재 갖고 있는 말의 개수를 입력받는다
- 그래서 실제 필요한 체스말의 개수를 맞추어 그 차를 구하면 되는 것
- 각, 체스말의 변수를 선언하여 초기 값으로 원래 정상적인 말의 개수를 설정 한 다음, 스캐너를 이용하여 수를 입력받고 입력받은 수들을 각 체스말에 맞추어 해당 변수에서 빼면 된다.
import java.util.Scanner;
public class chess {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int king = 1;
int queen = 1;
int rook = 2;
int bishop = 2;
int knight =2;
int pawn =8;
king = king - in.nextInt();
queen = queen - in.nextInt();
rook = rook - in.nextInt();
bishop = bishop - in.nextInt();
knight = knight - in.nextInt();
pawn = pawn - in.nextInt();
System.out.print(king + " ");
System.out.print(queen + " ");
System.out.print(rook + " ");
System.out.print(bishop + " ");
System.out.print(knight + " ");
System.out.print(pawn);
}
}