본문 바로가기

Coding Tests/백준 온라인

(Java) 백준온라인 1000번

<문제>

https://www.acmicpc.net/problem/1000

 

<컴파일 에러가 난 코드>

import java.util.scanner
public class Main{
    
    public static void main(String[] args){
        scanner sc = new scanner(System.in);
        int a = nextInt();
        int b = nextInt();
        System.out.println(a+b);
        sc.close();
    }
}

 

<정답 코드>

import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a+b);
        sc.close();
    }
}

<문제2>

https://www.acmicpc.net/problem/1001

 

<정답 코드>

import java.util.Scanner;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a-b);
        sc.close();
    }
}