[백준-Java]3003번.킹, 퀸, 룩, 비숍, 나이트, 폰

JINI·2022년 12월 14일
0

✔️3003.

- 문제.킹, 퀸, 룩, 비숍, 나이트, 폰

푸는 방법이 다양하지만 배열을 이용해서 풀이했다.

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에 원래 체스의 갯수만큼 배열 선언을 하고 입력받고 원래 개수에서 입력한 수를 빼면 된다.

profile
꾸준히 성장하는 개발자

0개의 댓글