1. 2557번 - Hello World

console.log("Hello World!");

2. 10718번 - We love Krili

console.log("강한친구 대한육군");
console.log("강한친구 대한육군");

3. 10171번 - 고양이

console.log(`\\    /\\`);
console.log(` )  ( ')`);
console.log(`(  /  )`);
console.log(` \\(__)|`);

4. 10172번 - 개

console.log(`|\\_/|`);
console.log(`|q p|   /}`);
console.log(`( 0 )"""\\`);
console.log(`|"^"\`    |`);
console.log(`||_/=\\\\__|`);

5. 1000번 - A+B

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

let input;
let output;

rl.on("line", line => {
  input = line.split(" ");
  output = input.reduce((prev, curr) => prev + +curr, 0);
  rl.close();
}).on("close", () => {
  console.log(output);
  process.exit();
});

6. 1001번 - A-B

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

let input;
let output;

rl.on("line", line => {
  input = line.split(" ");
  output = +input[0] - +input[1];
  rl.close();
}).on("close", () => {
  console.log(output);
  process.exit();
});

7. 10998번 - A*B

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

let input;
let output;

rl.on("line", line => {
  input = line.split(" ");
  output = input.reduce((prev, curr) => prev * curr, 1);
  rl.close();
}).on("close", () => {
  console.log(output);
  process.exit();
});

8. 1008번 - A/B

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

let input;
let output;

rl.on("line", line => {
  input = line.split(" ");
  output = input[0] / input[1];
  rl.close();
}).on("close", () => {
  console.log(output);
  process.exit();
});

9. 10869번 - 사칙연산

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

let input;
const output = [];

rl.on("line", line => {
  input = line.split(" ");
  input = input.map(v => +v);

  output.push(input[0] + input[1]);
  output.push(input[0] - input[1]);
  output.push(input[0] * input[1]);
  output.push(Math.floor(input[0] / input[1]));
  output.push(input[0] % input[1]);

  rl.close();
}).on("close", () => {
  output.forEach(v => console.log(v));
  process.exit();
});

10. 10430번 - 나머지

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

let input;
const output = [];

rl.on("line", line => {
  input = line.split(" ");
  input = input.map(v => +v);

  output.push((input[0] + input[1]) % input[2]);
  output.push(((input[0] % input[2]) + (input[1] % input[2])) % input[2]);
  output.push((input[0] * input[1]) % input[2]);
  output.push(((input[0] % input[2]) * (input[1] % input[2])) % input[2]);

  rl.close();
}).on("close", () => {
  output.forEach(v => console.log(v));
  process.exit();
});

11. 2588번 - 곱셈

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

const input = [];
const output = [];
let tempArray;

rl.on("line", line => {
  input.push(line);
}).on("close", () => {
  // 두 번째 입력받는 값 분리 및 역순 ( 단위별로 처리하기위해... 1의자리 10의자리 100의자리 )
  tempArray = input[1].split("").reverse();

  tempArray.forEach(v => output.push(input[0] * v));

  output.forEach(v => console.log(v));
  console.log(
    output.reduce((prev, curr, index) => {
      switch (index) {
        case 0:
          return curr * 1 + prev;
        case 1:
          return curr * 10 + prev;
        case 2:
          return curr * 100 + prev;
      }
    }),
  );
  process.exit();
});

마무리

입력받기

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

let input;
// const input = [];

rl.on("line", line => {
  // 1. 띄어쓰기로 구분
  input = line;
  rl.close();
  
  // 2. 줄단위로 구분
  input.push(line);
}).on("close", () => {
  console.log(input);
  process.exit();
});

0개의 댓글