Notice
Recent Posts
Recent Comments
Link
«   2026/04   »
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
Archives
Today
Total
관리 메뉴

새싹 개발자의 우당타당 개발일기

제로부터 시작하는 코테) 문자열 출력하기 본문

코딩테스트

제로부터 시작하는 코테) 문자열 출력하기

크누 2024. 10. 15. 03:12

문자열 출력하기

 

문제설명

문자열 str이 주어질 때, str을 출력하는 코드를 작성해 보세요.

 

제한사항

- 1 ≤ str의 길이 ≤ 1,000,000

- str에는 공백이 없으며, 첫째 줄에 한 줄로만 주어집니다.

 

입출력 예

입력 #1

HelloWorld!

출력 #1

HelloWorld!

 

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];

rl.on('line', function (line) {
    input = [line];
}).on('close',function(){
    str = input[0];
});

 

나의 풀이 

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];

rl.on('line', function (line) {
    input = [line];
}).on('close',function(){
    str = input[0];
    console.log(str)
});

말 그대로 출력만 하면 된다.

마지막에 console.log(str)추가