🎈문제
https://www.acmicpc.net/problem/3003
💬설명
- 각 숫자를 배열에 넣자.
- 숫자를 계산할 수 있도록 원래 숫자에서 빼주도록 하자.
⌨️ CODE
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] str = br.readLine().trim().split(" ");
int[] num = new int[6];
for(int i = 0 ; i < str.length ; i ++) {
if(i == 0 ) {
if(!str[i].equals("1")) {
num[i] = 1-Integer.parseInt(str[i]);
}
}else if(i == 1) {
if(!str[i].equals("1")) {
num[i] = 1-Integer.parseInt(str[i]);
}
}else if(i == 2) {
if(!str[i].equals("2")) {
num[i] = 2-Integer.parseInt(str[i]);
}
}else if(i == 3) {
if(!str[i].equals("2")) {
num[i] = 2-Integer.parseInt(str[i]);
}
}else if(i == 4) {
if(!str[i].equals("2")) {
num[i] = 2-Integer.parseInt(str[i]);
}
}else if(i == 5) {
if(!str[i].equals("8")) {
num[i] = 8-Integer.parseInt(str[i]);
}
}
}
for(int j = 0 ; j < num.length ; j++) {
System.out.print(num[j] + " ");
}
}
}
'CS > BaekJoon' 카테고리의 다른 글
[BaekJoon] 백준 10988번 팰린드롬인지 확인하기 - Java (0) | 2024.02.23 |
---|---|
[BaekJoon] 백준 2444번 별 찍기 - 7 - Java (0) | 2024.01.18 |
[BaekJoon] 백준 25083번 새싹 - Java (0) | 2024.01.18 |
[BaekJoon] 백준 11718번 그대로 출력하기 - Java (0) | 2024.01.18 |
[BaekJoon] 백준 5622번 다이얼 - Java (0) | 2024.01.18 |