inblog logo
|
silver
    알고리즘문제풀기

    [알고리즘문제풀기] 덧셈식 출력하기

    silver's avatar
    silver
    Apr 06, 2025
    [알고리즘문제풀기] 덧셈식 출력하기
    Contents
    문제내가 작성한 정답다른 사람들의 정답

    문제

    school.programmers.co.kr
    https://school.programmers.co.kr/learn/courses/30/lessons/181947

    내가 작성한 정답

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

    형식지정자

    1. %d (정수) : 10진수 정수. int, long, short, byte 등의 정수 타입
    1. %f (부동 소수점): 부동 소수점 수. float, double 타입. 기본적으로 소수점 이하 6자리까지 출력.
    1. %s (문자열): 문자열. String 타입.
    1. %b (boolean): boolean값. true 또는 false로 출력
    Share article

    silver

    RSS·Powered by Inblog