문자열 str
이 주어집니다.
문자열을 시계방향으로 90도 돌려서 아래 입출력 예와 같이 출력하는 코드를 작성해 보세요.
1 ≤ str
의 길이 ≤ 10
입력 #1
abcde
출력 #1
a
b
c
d
e
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];
[...str].forEach(a => console.log(a));
});
입력값 그대로 forEach
를 사용해 바로 출력한다.
다른 풀이
for(let i of str){console.log(i)}
for(let i = 0 ; i < str.length; i++)console.log(str[i])
[...str].map(x=>console.log(x))