Blue___
코딩배우는 학생🌎
Blue___
전체 방문자
오늘
어제
  • 코딩배우는 학생🧀 (242)
    • Algorithms (145)
      • BOJ[Java] (107)
      • Programmers[Java] (32)
      • Coding_Contest (3)
    • Web (22)
      • .NET Core C# (2)
      • Java (1)
      • Oracle SQL (7)
      • Web-ProJect (3)
      • Error처리 (1)
      • Web지식 (4)
      • Javascript (1)
      • Vue (3)
    • Git (4)
    • Java_beginner(Repl.it) (55)
      • Auto-Graded-Course(AP CS A) (54)
    • 프로젝트 직딩일기 (3)
    • Hanyang_Assignment (0)
    • 이모저모 (4)
      • 잡담 (1)
      • 2021 오픈소스 컨트리뷰터 아카데미 (1)
      • DDD - 6기! (1)
    • 북리뷰 (1)
      • 리팩토링 2판 (1)
      • 클린코드 (0)

블로그 메뉴

  • 🐰GITHUB
  • ☘️포트폴리오
  • 🌸MBC개발_투표 2022
  • 🍭MBC_APP

공지사항

인기 글

태그

  • 백준
  • REPL
  • AP CS A
  • 프로그래머스
  • Java tutorial
  • 코딩배우는 학생
  • repl.it
  • algorithm
  • 레플릿
  • auto-graded course
  • programmers
  • 알고리즘
  • 코딩
  • 코딩배우는학생
  • Bakjoon
  • 자바
  • coding
  • java basic
  • Java
  • 프로그래밍

최근 댓글

최근 글

티스토리

hELLO
Blue___

코딩배우는 학생🌎

034 - Big Number Program (From Decoding)
Java_beginner(Repl.it)/Auto-Graded-Course(AP CS A)

034 - Big Number Program (From Decoding)

2019. 12. 10. 19:33

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
12
13
14
15
16
17
18
19
20
21
import java.util.*;
 
public class Bakjoon {
    public static void main(String... args) {
             
                Scanner sc= new Scanner(System.in);
                System.out.print("#1: ");
                int num1 = sc.nextInt();
                System.out.print("#2: ");
                int num2 = sc.nextInt();
                //start on line 11
                int cnt=num1;
                if(num1%2==0) {cnt+=1;}
                while(cnt<=num2) {
                    System.out.print(cnt+" ");
                    cnt+=2;
                }
              }
            }
 
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs
반응형
저작자표시 (새창열림)

'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글

036 - Method Header Practice 1,2  (0) 2019.12.10
035 - Sum Odds in Range  (0) 2019.12.10
033 - For Loop Challenge 2 (optional)  (0) 2019.12.07
032 - For Loop Challenge 1 (optional)  (0) 2019.12.07
031 - Further For Loop Practice 7 (mIxEd CaSe)  (0) 2019.12.07
    'Java_beginner(Repl.it)/Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
    • 036 - Method Header Practice 1,2
    • 035 - Sum Odds in Range
    • 033 - For Loop Challenge 2 (optional)
    • 032 - For Loop Challenge 1 (optional)
    Blue___
    Blue___
    완전 연소한 불은 재를 남기지않는다 : 코딩배우는학생 🌎

    티스토리툴바