코딩테스트/프로그래머스 Lv. 0

[프로그래머스] Lv. 0 덧셈식 출력하기

촙오 개발자 2025. 1. 27. 15:57
반응형

덤색식 출력하기

 

문제 설명

 

요구사항

입력받은 두 숫자 덧셈식으로 출력

 

테스트

package lv0;

import java.util.Scanner;

public class 덧셈식_출력하기 {
	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)); // a + b 의 경우 문자열로 형변환 되는것을 방지 
	}
}

 

프로그래머스

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));
    }
}

 

결과

반응형