https://www.acmicpc.net/problem/9093

 

9093번: 단어 뒤집기

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split("\n");

const N = Number(input[0])

for(let i = 1 ; i <= N ; i++) {
    const string = input[i].split(" ");
    string.forEach((s, index) => {
        const tmp = s.split("");
        tmp.reverse();
        string[index] = tmp.join("");
    });
    console.log(string.join(" "));
};
728x90

+ Recent posts