Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- Method
- greedy
- Class
- geometry
- Binary Tree
- Binary Search
- sorting
- SQL
- 자바
- 코테
- Stack
- dynamic programming
- implement
- two pointers
- Counting
- 파이썬
- Matrix
- 코딩테스트
- database
- bit manipulation
- Data Structure
- array
- java
- 구현
- hash table
- Math
- string
- Tree
- Number Theory
- simulation
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 덧셈식 출력하기 본문
1. Input, Output, Example
- 두 정수 a, b가 주어질 때 다음과 같은 형태의 계산식을 출력하는 코드를 작성
2. Constraint
1) 1 ≤ a, b ≤ 100
3. Code
1) 첫 코드(2023/04/24)
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
System.out.println(a +" + "+ b + " = " + (a+b));
}
}
2) 비교를 위해 작성한 코드(2023/04/24)
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer token = new StringTokenizer(br.readLine());
int a = Integer.valueOf(token.nextToken()), b = Integer.valueOf(token.nextToken());
bw.write(a+" + "+b+" = "+(a+b));
bw.flush(); bw.close();
}
}
- 2번이 더 빠르다.
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 부분 문자열 (0) | 2023.04.24 |
---|---|
[프로그래머스/Lv.0] 배열에서 문자열 대소문자 변환하기 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 더 크게 합치기 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 주사위 게임 3 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 뒤에서 5등 위로 (0) | 2023.04.24 |