본문 바로가기

Java5

[Java] Practice - using method - emirp problem A emirp (prime spelled backward) is a non-palindromic prime number whose reversal is also a prime. - For example, 17 is a prime and 71 is a prime, so 17 and 71 are emirps. Write a program that displays the first 120 emirps. Display 10 numbers per line, separated by exactly one space You must re-use the Practice #1 methods for Practice #2. emirp이란 '수소'로, 17같이 17도 소수고 71도 소수인 수의 집합을 말한다. 한 자리수는 제외.. 2023. 3. 16.
[Java] BAEKJOON 1259 팰린드롬수 https://www.acmicpc.net/problem/1259 1259번: 팰린드롬수 입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다. www.acmicpc.net 이쪽 업계에선 엄청 유명한 문제다. 재귀로 푸는 팰린드롬 문제가 많기 때문. 그런데 오늘 문제는 단순해서 그냥 method 몇 번 쓰면 풀린다. method는 숫자를 뒤집는 reverse() 함수와 팰린드롬 수가 맞는지 확인하는 isPalindrome()함수로 구성된다. import java.util.Scanner; public class Main { public static void main(String[] a.. 2023. 3. 16.
[Java] 가위바위보 게임 practice A program that plays the scissor-rock-paper game. A program randomly generates a number 0, 1, or 2 representing scissors, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Let the user continuously play until either the user or the computer wins two times more than their opponent (e.. 2023. 3. 9.