본문 바로가기

알고리즘

(176)
[Hackerrank] Class vs. Instance Objective In this challenge, we're going to learn about the difference between a class and an instance; because this is an Object Oriented concept, it's only enabled in certain languages. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Person class with an instance variable, age, and a contructor that takes an integer, initialAge, as a parameter. The co..
[Baekjoon] 10171번 / 고양이 문제 아래 예제와 같이 고양이를 출력하시오. 입력 없음 출력 고양이를 출력한다. 예제 출력 \ /\ ) ( ') ( / ) \(__)| import java.util.*; public class Main { public static void main(String[] args) { System.out.println("\\ /\\"); System.out.println(" ) ( ')"); System.out.println("( / )"); System.out.println(" \\(__)|"); } }
[Baekjoon] 8393번 / 합 문제 n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 n (1
[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