본문 바로가기

Beakjoon&프로그래머스/Java139

[백준/Java] 5596번 시험 점수 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] score1 = new int[4]; int[] score2 = new int[4]; int sum1 = 0; int sum2 = 0; for (int i = 0; i < 4; i++) { score1[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { score2[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { sum1 += score1[i]; sum2 += score2[i]; } .. 2022. 4. 17.
[백준/Java] 5575번 타임 카드 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int i = 0; i < 3; i++) { int h1 = sc.nextInt(); int m1 = sc.nextInt(); int s1 = sc.nextInt(); int h2 = sc.nextInt(); int m2 = sc.nextInt(); int s2 = sc.nextInt(); int time1 = h1 * 3600 + m1 * 60 + s1; int time2 = h2 * 3600 + m2 * 60 + s2; int time = time2 - time1.. 2022. 4. 17.
[백준/Java] 11720번 숫자의 합 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String num = sc.next(); int result = 0; for (int i = 0; i < num.length(); i++) { result += (int) num.charAt(i) - '0'; } System.out.println(result); } } 2022. 4. 17.
[백준/Java] 8958번 OX퀴즈 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { String ox = sc.next(); int score = 0; int cnt = 0; for (int j = 0; j < ox.length(); j++){ cnt += 1; if (ox.charAt(j) == 'O') { score += cnt; } else { cnt = 0; } } System.out.println(score); } } } 2022. 4. 17.
[백준/Java] 2920번 음계 -Code import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] nums = new int[8]; int[] arr1 = {1, 2, 3, 4, 5, 6, 7, 8}; int[] arr2 = {8, 7, 6, 5, 4, 3, 2, 1}; for (int i = 0; i < nums.length; i++) { nums[i] = sc.nextInt(); } if (Arrays.equals(nums, arr1)){ System.out.println("ascending"); } else if.. 2022. 4. 17.
[백준/Java] 10952번 A+B - 5 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true){ int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0){ break; } System.out.println(a + b); } } } 2022. 4. 17.