본문 바로가기

전체 글

[Baekjoon] 2742번 / 기찍 N 문제 자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다. 출력 첫째 줄부터 N번째 줄 까지 차례대로 출력한다. 예제 입력 5 예제 출력 5 4 3 2 1 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i=N; i>0; i--) { System.out.println(i); } } } 더보기
[Hackerrank] Intro to Conditional Statements Objective In the challenge, we learn about conditional statements. Check out the Turorial tab for learning materials and an instructional video. Task Given an integer, n, perform the following confitional actions: if n is odd, print Weird if n is even and in the inclusive range of 2 to 5, print Not Weird if n is even and in the inclusive range of 6 to 20, print Weird if n is even and greater tha.. 더보기
[Baekjoon] 2439번 / 별 찍기 - 2 문제 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오. 입력 첫째 줄에 N(1 더보기
[Baekjoon] 10172번 / 개 문제 아래 예제와 같이 개를 출력하시오. 입력 없음. 출력 개를 출력한다. 예제 출력 |\_/| |q p| /} ( 0 )"""\ |"^"` | ||_/=\\__| import java.util.*; public class Main { public static void main(String[] args) { System.out.println("|\\_/|"); System.out.println("|q p| /}"); System.out.println("( 0 )\"\"\"\\"); System.out.println("|\"^\"` |"); System.out.println("||_/=\\\\__|"); } } - 쌍따옴표(")를 출력하고싶을땐 역슬레시(\)를 앞에 추가해준다. - 역슬레시를 출력하고싶을때.. 더보기
[Baekjoon] 2741번 / N 찍기 문제 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다. 출력 첫째 줄부터 N번째 줄 까지 차례대로 출력한다. 예제 입력 5 예제 출력 1 2 3 4 5 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i=1; i 더보기
[Baekjoon] 10430번 / 나머지 문제 (A+B)%C는 ((A%C) + (B%C))%C 와 같을까? (A×B)%C는 ((A%C) × (B%C))%C 와 같을까? 세 수 A, B, C가 주어졌을 때, 위의 네 가지 값을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000) 출력 첫째 줄에 (A+B)%C, 둘째 줄에 ((A%C) + (B%C))%C, 셋째 줄에 (A×B)%C, 넷째 줄에 ((A%C) × (B%C))%C를 출력한다. 예제 입력1 5 8 4 예제 출력1 1 1 0 0 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(Syst.. 더보기
[Hackerrank] Operators Objective In this challenge, you will work with arithmetic operators. Check out the Turtorial tab for learning materials and an instructional video. Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Round the res.. 더보기
[Hackerrank] Data Types Objective Today, we're discussing data types. check out the Tutorial tab for learning materials and an instructional video! Task Complete the code in the editor below. The variables i, d, and s are already declared and initalized for you. You must: 1. Declare 3 variables: one of type int, one of type double, and one of type String. 2. Read 3 lines of input from stdin (according to the sequence g.. 더보기