-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_type.js
More file actions
34 lines (34 loc) · 1.03 KB
/
input_type.js
File metadata and controls
34 lines (34 loc) · 1.03 KB
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
31
32
33
34
// 1. 입력값이 한 개일 때(한 줄)
const fs = require("fs");
const input = fs.readFileSync("/dev/stdin").toString().trim();
// 2. 입력값이 여러 개일 때(한 줄에 공백으로 구분)
/* ex)
110 78 158
*/
const fs = require("fs");
const input2 = fs.readFileSync("/dev/stdin").toString().trim().split(" ");
// 3. 입력값이 여러 줄일 때
/* ex)
110
78
158
*/
const fs = require("fs");
const input3 = fs.readFileSync("/dev/stdin").toString().trim().split("\n");
// 4. 입력값이 첫 번째 줄에는 입력 값의 길이(n), 두 번째 줄에 공백으로 구분된 입력값이 주어질 때
/* ex)
3
110 78 158
*/
const fs = require("fs");
const [n1, input4] = fs.readFileSync("/dev/stdin").toString().trim().split("\n");
const inputArr = input.trim().split(" ");
// 5. 입력값이 첫 번째 줄에는 입력 값의 길이(n), n개의 줄에 걸쳐서 한 줄에 하나의 입력값이 주어질 때
/* ex)
3
110
78
158
*/
const fs = require("fs");
const [n2, input5] = fs.readFileSync("/dev/stdin").toString().trim().split("\n");