Skip to content

Commit

Permalink
feature: 단어 뒤집기.js
Browse files Browse the repository at this point in the history
  • Loading branch information
1two13 committed Jul 15, 2022
1 parent 71458a6 commit 9042150
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion input.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<open>tag<close>
2
I am happy today
We want to win the first prize
25 changes: 25 additions & 0 deletions 구현/단어 뒤집기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
입력값 => 첫째 줄은 개수
출력값 => 입력값을 모두 뒤집어서 출력하기
*/

const fs = require("fs");
const file = "/dev/stdin";
// const file = "../input.txt";

function main() {
const input = fs.readFileSync(file).toString().split("\n");
let result = "";

for (let i = 1; i <= input[0]; i++) {
let splitIP = input[i].split(" "); // [ 'I', 'am', 'happy', 'today' ]

for (let j = 0; j < splitIP.length; j++) {
result += splitIP[j].split("").reverse().join("") + " ";
}
console.log(result);
result = "";
}
}

main();

0 comments on commit 9042150

Please sign in to comment.