반응형
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.print(a);
System.out.print(" + ");
System.out.print(b);
System.out.print(" = ");
System.out.print(a+b);
}
}
아무리 해도 한줄에 출력하는거 못하겠다 했는데
c언어 스타일로 해도 풀린다.
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);
}
}
C언어가 편하다..ㅠㅠ
반응형
'코딩해요 > JAVA' 카테고리의 다른 글
[프로그래머스] 대소문자 바꿔서 출력하기 (0) | 2024.08.06 |
---|---|
[프로그래머스] 문자열 반복해서 출력하기 (0) | 2024.08.06 |
[프로그래머스] a와 b 출력하기 (0) | 2024.08.06 |
[프로그래머스] 문자열 출력하기 (0) | 2024.08.06 |
[프로그래머스] PCCE 기출문제 10번/데이터 분석 (0) | 2024.07.30 |