프로그래밍(programming)

[백준 문제 1001]_자바 A-B

정보나눔중 2020. 11. 29. 00:39
반응형

단계별로 풀어보기

 

1단계 : 입출력과 사칙연산

-6단계 : a와 b를 입력 받은 다음, a-b를 출력

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.*;
 
public class Main {
    
    public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
       
        while(a<0 || a>10 || b<0 || b>10){
            //System.out.println("a,b 두수를 0~10 사이로 입력하세요.");
            a = scan.nextInt();
            b = scan.nextInt();
        }
        
        System.out.println(a-b);
        
    }    
}
 
cs
반응형