본문 바로가기

Beakjoon&프로그래머스/Java139

[백준/Java] 10797번 10부제 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int day = sc.nextInt(); int cnt = 0; for (int i = 0; i < 5; i++) { int car = sc.nextInt(); if (car % 10 == day) { cnt++; } } System.out.println(cnt); } } 2022. 4. 18.
[백준/Java] 14681번 사분면 고르기 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); if (x > 0 && y > 0) { System.out.println(1); } else if (x 0) { System.out.println(2); } else if (x 0 && y < 0) { System.out.println(4); } } } 2022. 4. 18.
[백준/Java] 20499번 Darius님 한타 안 함? -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] kda = sc.nextLine().split("/"); int result = Integer.parseInt(kda[0]) + Integer.parseInt(kda[2]); int d = Integer.parseInt(kda[1]); if (result < d || d == 0) { System.out.println("hasu"); } else { System.out.println("gosu"); } } } 2022. 4. 18.
[백준/Java] 14924번 폰 노이만과 파리 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int s = sc.nextInt(); int t = sc.nextInt(); int d = sc.nextInt(); System.out.println(d / (s * 2) * t); } } 2022. 4. 18.
[백준/Java] 10809번 알파벳 찾기 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[26]; for (int i = 0; i < 26; i++) { arr[i] = -1; } String s = sc.nextLine(); for (int i = 0; i < s.length(); i++) { int n = s.charAt(i) - 'a'; if (arr[n] == -1) { arr[n] = i; } } for (int i : arr) { System.out.print(i + " "); } } } 2022. 4. 18.
[백준/Java] 3052번 나머지 -Code import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList list = new ArrayList(); for (int i = 0; i < 10; i++){ int num = sc.nextInt() % 42; if (!list.contains(num)){ list.add(num); } } System.out.println(list.size()); } } 2022. 4. 18.