반응형
백준 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=" ")
문제 출처
반응형
'Coding > BAEKJOON' 카테고리의 다른 글
[백준] 5554번 심부름 가는 길 풀이 코드 (C/C++/Java 자바/Python 파이썬) (0) | 2021.10.17 |
---|---|
[백준] 10170번 NFC West vs North 풀이 코드 (C/C++/Java 자바/Python 파이썬) (0) | 2021.10.15 |
[백준] 10926번 ??! 풀이 코드 (C/C++/Java 자바/Python 파이썬) (2) | 2021.10.13 |
[백준] 9654번 나부 함대 데이터 풀이 코드 (C/C++/Java 자바/Python 파이썬) (0) | 2021.10.12 |
[백준] 5339번 콜센터 풀이 코드 (C/C++/Java 자바/Python 파이썬) (0) | 2021.10.11 |