반응형

백준 3003번 킹, 퀸, 룩, 비숍, 나이트, 폰 풀이 코드

C | C++ | Java | Python


풀이

정해진 말의 수를 배열로 담아두고 입력값과의 차이를 출력합니다.

코드

#include <stdio.h>

int main() {
    int chess[6]={1,1,2,2,2,8}, i, now;
    for(i=0; i<6; i++) {
        scanf("%d", &now);
        printf("%d ", chess[i]-now);
    }
    return 0;
}
#include <iostream>
using namespace std;

int main() {
    int chess[6]={1,1,2,2,2,8}, now;
    for(int i=0; i<6; i++) {
        cin>>now;
        cout<<chess[i]-now<<' ';
    }
    return 0;
}
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] chess = {1, 1, 2, 2, 2, 8};
        for(int i=0; i<6; i++) {
            int now = sc.nextInt();
            System.out.print((chess[i] - now) + " ");
        }
    }
}
chess = [1, 1, 2, 2, 2, 8]
now = list(map(int, input().split()))
for i in range(6):
    print(chess[i]-now[i], end=" ")

문제 출처

https://www.acmicpc.net/problem/3003

반응형

+ Recent posts