문제설명
두 정수 a, b가 주어질 때 다음과 같은 형태의 계산식을 출력하는 코드를 작성해 보세요.
a + b = c
제한사항
1 ≤ a, b ≤ 100
입출력 예
입력 #1
4 5
출력 #1
4 + 5 = 9
풀이
JAVA
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));
}
}
Python
a, b = map(int, input().strip().split(' '))
print(f"{a} + {b} = {a + b}")
C
#include <stdio.h>
int main(void) {
int a;
int b;
scanf("%d %d", &a, &b);
printf("%d + %d = %d", a, b, a + b);
return 0;
}
'프로그래머스 Lv.0' 카테고리의 다른 글
Lv.0 문자열 돌리기 (0) | 2025.01.14 |
---|---|
Lv.0 문자열 붙여서 출력하기 (0) | 2025.01.14 |
Lv.0 특수문자 출력하기 (0) | 2025.01.13 |
Lv.0 대소문자 바꿔서 출력하기 (0) | 2025.01.12 |
Lv.0 문자열 반복해서 출력하기 (0) | 2025.01.12 |