Develop
[프로그래머스] 덧셈식 출력하기 본문
문제
내풀이
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를 써서 출력하는 방법이 있다는 것을 알았다
간단하게 사용하기 좋을듯
'개인 공부 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 문자열 돌리기 (0) | 2024.01.10 |
---|---|
[프로그래머스] 홀짝 구분하기 (1) | 2024.01.09 |
[프로그래머스] 특수문자 출력하기 (0) | 2024.01.09 |
[프로그래머스] 대소문자 바꿔서 출력하기 (0) | 2024.01.08 |
[프로그래머스] 문자열 반복해서 출력하기 - repeat (0) | 2024.01.05 |