2026.01.23(FRI)_54일차
1. 문제
문제 설명
두 정수
a, b가 주어질 때 다음과 같은 형태의 계산식을 출력하는 코드를 작성해 보세요.a + b = c제한사항
- 1 ≤
a,b≤ 100
입출력 예
입력 #1
4 5출력 #1
4 + 5 = 92. 풀이
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));
}
}3. 다른 사람의 풀이
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);
}
}Share article