연습장
07. 문자열 붙여서 출력하기 본문
Q. 두 개의 문자열 str1, str2가 공백으로 구분되어 입력으로 주어집니다.
입출력 예와 같이 str1과 str2을 이어서 출력하는 코드를 작성해 보세요.
제한사항
1 ≤ str1, str2의 길이 ≤ 10
입력
apple pen
출력
applepen
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let input = [];
rl.on('line', function (line) {
input = line.split(' ');
}).on('close', function () {
str1 = input[0];
str2 = input[1];
});
console.log(input)
앞서 했던 stringstringstringstringstring 문제를 생각하면 간단하게 풀린다.
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let input = [];
rl.on('line', function (line) {
input = line.split(' ');
}).on('close', function () {
str1 = input[0];
str2 = input[1];
console.log(str1+str2)
});
console.log(input) // 필요없는 코드는 지우자
'프로그래머스 > 0단계' 카테고리의 다른 글
09. 홀짝 구분하기 (0) | 2023.06.17 |
---|---|
08. 문자열 돌리기 (2) | 2023.06.17 |
06. 덧셈식 출력하기 (0) | 2023.06.17 |
05. 특수문자 출력하기 (0) | 2023.06.17 |
04. 대소문자 바꿔서 출력하기 (0) | 2023.06.17 |