Develop

[프로그래머스] 덧셈식 출력하기 본문

개인 공부/프로그래머스

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

개발 기록 2024. 1. 8. 00:55

문제

 

 

내풀이

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

 

 

다른 답

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.printf("%d + %d = %d",a,b,a+b);
    }
}

 

느낀점

씨언어처럼 %d를 써서 출력하는 방법이 있다는 것을 알았다

간단하게 사용하기 좋을듯