๊ด€๋ฆฌ ๋ฉ”๋‰ด

bom's happy life

[JAVA] ๋ง์…ˆ์‹ ์ถœ๋ ฅํ•˜๊ธฐ ๋ณธ๋ฌธ

Algorithm๐Ÿ’Œ/ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

[JAVA] ๋ง์…ˆ์‹ ์ถœ๋ ฅํ•˜๊ธฐ

bompeach 2023. 4. 22. 23:48

๋ฌธ์ œ ์„ค๋ช… :

๋‘ ์ •์ˆ˜ a, b๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ์˜ ๊ณ„์‚ฐ์‹์„ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด์„ธ์š”.

a + b = c

 

์ œํ•œ์‚ฌํ•ญ :

๐Ÿ”Ž 1 ≤ a, b ≤ 100

 

์ž…์ถœ๋ ฅ ์˜ˆ :

์ž…๋ ฅ #1

4 5

์ถœ๋ ฅ #1

4 + 5 = 9

 

 

๋ฌธ์ œ

import java.util.Scanner;

public class Solution {
    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);
    }
}

 

 

์ •๋‹ต 1

import java.util.Scanner;

public class Solution {
    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 + " = " + (a + b));
    }
}

 

 

์ •๋‹ต 2

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = a + b;

        System.out.println(a + " + " + b + " = " + sum);
    }
}