💡문제 풀이/백준 - JAVA 36

윤년 / 2753

정보 분류 : 조건문 문제 문제링크 풀이 import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int year = sc.nextInt(); if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { System.out.println(1); } else { System.out.println(0); } } } 풀이 후기 윤년은 연도가 4의 배수(year % 4)이면서, 100의 배수(year % 100)가 아닐 때(!=) 또는(||(OR)) 400의 배수(year % 400)일 때이다.

두 수 비교하기 / 1330

정보 분류 : 조건문 문제 문제링크 풀이 import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); if(a < b) { System.out.println(""); } else { System.out.println("=="); } } } 풀이 후기 두 개의 숫자를 입력 받는다. 조건문(if-else if-else)를 이용하여 두 개의 숫자를 비교하여 출력하는 문구를 다르게 했다.

꼬마 정민 / 11382

정보 분류 : 입출력과 사칙연산 단계 문제 문제링크 풀이 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long A = sc.nextLong(); long B = sc.nextLong(); long C = sc.nextLong(); long sum = A + B + C; System.out.print(sum); } } 풀이 후기 처음엔 런타임 에러(InputMismatch)라는 오류가 떴었다. 해당 오류는 java.lang.IndexOutOfBoundsException으로 범위에서 벗어나면 생기는 오류이다. 입력받는 세개의 숫자들은 1 ≤ A..

곱셈 / 2588

정보 분류 : 입출력과 사칙연산 단계 문제 문제링크 풀이 import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a * (b % 10));//첫째줄 System.out.println(a * (b % 100 / 10));//둘째줄 System.out.println(a * (b / 100));//셋째줄 System.out.println(a * b);//마지막째줄 } } 풀이 후기 -