백준 (Java)
-
백준 2480 주사위 세개백준 (Java) 2022. 6. 10. 01:36
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(); int c = sc.nextInt(); // 모든 주사위가 같을 때 if(a==b&&b==c){ System.out.println(10000+a*1000);} // 두 주사위만 같을 때 else if(a==b && b!=c){ System.out.println(1000+a*100);} else if(a==c && c!=b){ System.out.println(1000+a*100); }else if(b==c && c!=a)..
-
백준 2525 오븐 시계백준 (Java) 2022. 6. 10. 01:03
- 전체 시간 계산 후 시간 / 분 단위로 계산 - 24시 자정을 넘어가면 시를 0으로 세팅하여 계산 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int m = sc.nextInt(); int e = sc.nextInt(); // 시간 계산 int total = h*60 + m + e; h = total/60; m = total%60; // 24시간 계산 if(h>23) h=h-24; // 출력 System.out.println(h+" "+m); } } https://www.acmicpc.net/prob..
-
백준 25083 새싹백준 (Java) 2022. 6. 10. 00:54
* 이스케이프 시퀀스에 대해 이해하기 - 이스케이프 시퀀스는 기본적인 방법으로 입력할 수 없는 문자를 입력하기 위해 사용 - 백슬래쉬(\)를 붙여 사용 (\+문자) import java.util.*; public class Main { public static void main(String[] args){ System.out.println(" ,r\'\"7"); System.out.println("r`-_ ,' ,/"); System.out.println(" \\. \". L_r'"); System.out.println(" `~\\/"); System.out.println(" |"); System.out.println(" |"); } } https://www.acmicpc.net/problem/25083..
-
백준 10951 while문 이용하여 두 수의 합 구하기백준 (Java) 2022. 2. 9. 01:39
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNextInt()){ int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a+b); } } } https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net ※ hasNextInt() : while문 - 조건문 자리에 위치 : Scanner로 입력받는 수의 형태가 int일 때만 반복..
-
백준 10952 while문 사용하여 반복문 출력하기 (A+B - 5)백준 (Java) 2022. 2. 9. 01:27
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int i = 0; while(true){ int a = sc.nextInt(); int b = sc.nextInt(); if(a==0 && b==0) break; System.out.println(a+b); i++; } } } https://www.acmicpc.net/problem/10952 10952번: A+B - 5 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net [Key point] 입력의 마지막에는 0 두 개가 들어온다. • 다음 조..
-
백준 10871 x보다 작은 수백준 (Java) 2022. 2. 9. 01:10
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); for(int i=1;i a) { System.out.print(a + " "); } } } } https://www.acmicpc.net/problem/10871 10871번: X보다 작은 수 첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다. www.acmicpc.net ..