[2021 하계 모각코] 2회차 결과

규리(●'◡'●)·2021년 7월 14일
0

2021 하계 모각코

목록 보기
5/14

목표 - 윷놀이, 주사위게임을 구현한다.

윷놀이
주사위게임

결과

윷놀이와 주사위 게임을 정상적으로 구현하였다.

[1차 목표] 윷놀이 게임 구현
▼소스코드

import java.util.*;
import java.io.*;
public class yutgame_2490 {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		String list[] = new String[3];
		String result[] = new String[4];
		for (int i = 0; i < 3; i++) {
			list[i] = sc.nextLine().replace(" ", "");
			int count1 = 0;
			int count0 = 0;
			for (int k = 0; k < 4; k++) {
				if (list[i].charAt(k) == '0') {
					count0++;
				} else {
					count1++;
				}
			}
			if (count0 == 1 && count1 == 3) result[i] = "A";
			if (count0 == 2 && count1 == 2) result[i] = "B";
			if (count0 == 3 && count1 == 1) result[i] = "C";
			if (count0 == 4 && count1 == 0) result[i] = "D";
			if (count0 == 0 && count1 == 4) result[i] = "E";
		}
		for (int i = 0; i < 3; i++) {
			System.out.println(result[i]);
		}
	}
}

[2차 목표] 주사위 게임 구현
▼소스코드

import java.util.*;
import java.io.*;
import java.math.*;
public class dice_2476 {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		int val = sc.nextInt();
		String list[] = new String[val];
		int result[] = new int[val];
		int max = 0;
		for (int i = 0; i < val; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (a == b && b == c) {
				result[i] = a * 1000 + 10000;
			} else if (a == b || a == c || b == c) {
				if (a == b || a == c) result[i] = a * 100 + 1000;
				if (b == c) result[i] = b * 100 + 1000;
			} else if (a != b && a != c && b != c) {
				result[i] = Math.max(a, Math.max(b, c)) * 100;
			}
		}
		for (int i = 0; i < val; i++) {
			max = (max < result[i]) ? result[i] : max;
		}
		System.out.println(max);
	}
}

느낀점

난이도가 쉬워서 해결하는데 큰 어려움은 없었지만 코드의 가독성이 떨어지는것같아 다음 회차부턴 정리가 필요할것같다.

0개의 댓글