[백준][Java] 1316 - 그룹 단어 체커
2023. 8. 5. 15:17
백준/Java
https://www.acmicpc.net/problem/10807 import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int count = 0; int N = sc.nextInt(); for (int loop = 0; loop < N; loop++) { if (groupWordCheck() == true) { count++; } } System.out.print(count); } public static boolean groupWordCheck() { boolean[] groupWordCheck = new boolean[2..
[백준][Java] 4673 - 셀프 넘버
2023. 8. 1. 01:41
백준/Java
https://www.acmicpc.net/problem/4673 public class Main { public static int d(int number) { int sum = number; /* 1234가 들어온다면 첫 번째 while문 sum = sum + (1234 % 10) -> 1234 + 4 number = 123 두 번째 while문 sum = sum + (1234 + 4) + 3 number = 12 ... */ while (number != 0) { sum = sum + (number % 10); number /= 10; } return sum; } public static void main(String[] args) { /* 1 ~ 10000 사이의 셀프 넘버를 구해야 함 인덱스는 ..
[백준][Java] 2743 - 단어 길이 재기
2023. 7. 28. 23:19
백준/Java
https://www.acmicpc.net/problem/2743 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String userInput = scanner.nextLine(); System.out.println(userInput.length()); } } Scanner scanner = new Scanner(System.in); String userInput = scanner.nextLine(); System.out.println(userInput.length()); 사용자로부터 nextLine()을 이용하여 문자열을..
[백준][Java] 11654 - 아스키 코드
2023. 7. 27. 20:38
백준/Java
https://www.acmicpc.net/problem/11654 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); char userInput = scanner.next().charAt(0); int asciiNum = (int)userInput; System.out.println(asciiNum); } } char userInput = scanner.next().charAt(0); int asciiNum = (int)userInput; 사용자가 입력한 알파벳을 userInput에 대입합니다. charAt()은 String ..
[백준][Java] 2738 - 행렬 덧셈
2023. 7. 27. 13:54
백준/Java
https://www.acmicpc.net/problem/2738 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int M = scanner.nextInt(); int[][] numArr = new int[N][M]; for (int row = 0; row < N; row++) { for (int column = 0; column < M; column++) { numArr[row][column] = scanner.nextInt(); // 기존 값 추가 } } for (int ..