teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

追記

2020/07/07 22:02

投稿

shosinnshadesu
shosinnshadesu

スコア93

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,16 @@
1
1
  ```javascript
2
+ process.stdin.resume();
3
+ process.stdin.setEncoding('utf8');
4
+
5
+ let lines = [];
6
+ let reader = require('readline').createInterface({
7
+ input: process.stdin,
8
+ output: process.stdout
9
+ });
10
+ reader.on('line', (line) => {
11
+ lines.push(line);
12
+ });
13
+ reader.on('close', () => {
2
14
  let line = lines[0].split(' ');
3
15
  for (i = 1; i<line[1]; i++) {
4
16
  let x = 100/line[1];
@@ -21,6 +33,8 @@
21
33
  console.log('A');
22
34
  }
23
35
  }
36
+ });
37
+
24
38
  ```
25
39
  ```
26
40
  入力

1

追記

2020/07/07 22:02

投稿

shosinnshadesu
shosinnshadesu

スコア93

title CHANGED
File without changes
body CHANGED
@@ -22,5 +22,18 @@
22
22
  }
23
23
  }
24
24
  ```
25
+ ```
26
+ 入力
27
+ 3 25
28
+ -2 17
29
+ -7 20
30
+ 2 24
31
+ ```
32
+ ```
33
+ 期待される出力
34
+ C
35
+ A
36
+ B
37
+ ```
25
38
  上のコードを書くと、splitのところでCannot read property 'split' of undefinedこのようなエラーになってしまいます。
26
39
  どうしたらよいのでしょうか?