Java tutorial

    034 - Big Number Program (From Decoding)

    034 - Big Number Program (From Decoding)

    You are given two inputs: int num1; int num2; You can assume that the following: num2 > num1 ==> TRUE You are to write a program that will print out all the ODD numbers in between num1 and num2 inclusive. Your output should all be on one line, separated by spaces. Sample input/output: #1: 3 #2: 11 3 5 7 9 11 #1: 4 #2: 20 5 7 9 11 13 15 17 19 #1: -2 #2: 6 -1 1 3 5 Solution 1 2 3 4 5 6 7 8 9 10 11..

    [백준/5612번] 터널의 입구와 출구(JOI 2006 모의고사 2)[Java]

    [백준/5612번] 터널의 입구와 출구(JOI 2006 모의고사 2)[Java]

    문제 상근이는 남산1호터널의 입구와 출구에서 1분에 통과하는 차량의 수를 조사했다. 이때, 터널에 차량이 가장 많이 있었을 때, 몇 대 있었는지 구하는 프로그램을 작성하시오. 입력 첫째 줄에 조사한 시간 n이 주어진다. 둘째 줄에는 조사를 시작할 때, 터널 안에 들어있는 차량의 수 m이 주어진다. 다음 n개 줄의 i번째 줄(i = 1 ~ n)의 정보는 조사를 시작한지 (i-1)분이 경과한 시점부터 i분 경과할 때 까지 1분에 입구를 통과한 차의 수와 출구를 통과한 차의 수이다. n은 10000보다 작거나 같고, 1분에 통과하는 차량의 수는 100이하이다. 출력 조사 시작하고 j분이 지난 시점 (j = 0~n)에서 터널 안에 있는 차량의 수를 Sj라고 하자. 이때, Sj의 최댓값을 출력한다. 만약, 터널 ..

    [백준/17009번] Winning Score  ( CCC 2019 Junior Division)[Java]

    [백준/17009번] Winning Score ( CCC 2019 Junior Division)[Java]

    Problem You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a 2-point field goal, or a 1-point free throw. You know the number of each of these types of scoring for the two teams: the Apples and the Bananas. Your job is to determine which team won, or if the game ended in a tie. Input The first three lines of input describe the scoring of the Apples,..

    [백준/13597번] Tri-du( A Primeira Fase da Maratona de Programação 2015) [Java]

    [백준/13597번] Tri-du( A Primeira Fase da Maratona de Programação 2015) [Java]

    Problem Tri-du é um jogo de cartas derivado do popular jogo de Truco. O jogo utiliza um baralho normal de 52 cartas, com treze cartas de cada naipe, mas os naipes são ignorados. Apenas o valor das cartas,considerados como inteiros de 1 a 13, são utilizados. No jogo, cada jogador recebe três cartas. As regras são simples: Um trio (três cartas de mesmo valor) ganha de uma dupla (duas cartas de mes..

    [백준/10990번] 별 찍기-15 [Java]

    [백준/10990번] 별 찍기-15 [Java]

    문제 예제를 보고 규칙을 유추한 뒤에 별을 찍어 보세요. 입력 첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다. 출력 첫째 줄부터 N번째 줄까지 차례대로 별을 출력한다. 풀이 앞에서 나오는 공간을 카운트 해주는 first_count, 그리고 별과 별 사이의 공간을 카운트 해주는 변수 last_count를 선언해주고 first_count는 개행될때마다 -1씩 해주고 last_count는 +1씩해주면서 카운트가 끝날때마다 별 하나를 찍어준다. ㅇㅅㅇ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import java.util.Scanner; class Bakjoon { public static void main(String[] args) throws Exce..

    033 - For Loop Challenge 2 (optional)

    033 - For Loop Challenge 2 (optional)

    Write code that will take in a String input and check to see if it is a palindrome or not. A palindrome means that the characters are the same forwards and backwards, ignoring spaces. Examples of palindromes: racecar was it a car or a cat I saw never odd or even rats live on no evil star Your check should be case insensitive too. For example, "Bob" is a palindrome, despite the first B being capi..

    032 - For Loop Challenge 1 (optional)

    032 - For Loop Challenge 1 (optional)

    The fibonacci sequence is a sequence of numbers in which the next number is the sum of the previous two numbers. The first two numbers of the fibonacci sequence are 0, 1. The first 8 numbers of the fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13 Write some code to print out the first X numbers of the fibonacci sequence. Your output should be on one line, with each number separated by a space. You..

    030 - Further For Loop Practice 6 (reverse string)

    030 - Further For Loop Practice 6 (reverse string)

    Given the following inputs: String s; Write a for loop that will print out the reverse of the string. Sample input/outputs: In: manhattan out: nattahnam In: processor out: rossecorp In: racecar out: racecar Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("In:"); Str..

    029 - Further For Loop Practice 5 (printing characters)

    029 - Further For Loop Practice 5 (printing characters)

    Given the following inputs: String s; Write a for loop that will print out each letter of the string s, separated by spaces, on the same line. Sample input/outputs: In: hello out: h e l l o In: covert out: c o v e r t In: blasphemy out: b l a s p h e m y Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new ..

    028 - Further For Loop Practice 4 (repeating X times)

    028 - Further For Loop Practice 4 (repeating X times)

    Given the following inputs: int x; Write a for loop that will print out "AP CS A" x number of times, new line per print. Sample input/outputs: In: 3 AP CS A AP CS A AP CS A In: 5 AP CS A AP CS A AP CS A AP CS A AP CS A In: 1 AP CS A Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new Scanner(System.in); Sy..

    027 - Further For Loop Practice 3 (descending)

    027 - Further For Loop Practice 3 (descending)

    Given the following inputs: int x; Write a for loop that will print out a series of numbers starting at one less than x and ending at 0. Sample input/outputs: In: 7 out: 6 5 4 3 2 1 0 In: 12 out: 11 10 9 8 7 6 5 4 3 2 1 0 In: 20 out:19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Main { public static void main(String[] a..

    026 - Further For Loop Practice 2 (skipping by 3s)

    026 - Further For Loop Practice 2 (skipping by 3s)

    Given the following inputs: int x; Write a for loop that will print out a series of numbers starting at 0 and ending before x, skipping 3 each time (excluding x). Sample input/outputs: In: 7 out: 0 3 6 In: 12 out: 0 3 6 9 In: 20 out: 0 3 6 9 12 15 18 HINT: You'll want to change the increment part of the for loop! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import java.util.*; class Bakjoon { public stat..