1. 2739번 - 구구단

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

let input = null;
let output = [];

rl.on("line", line => {
  input = +line;
  output = Array(9)
    .fill()
    .map((v, i) => i + 1);

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

2. 10950번 - A+B-3

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

let input = [];
let output = null;
let limit = 999;

rl.on("line", line => {
  input.push(line);
  limit = +input[0];

  // 최초 입력한 값만큼만 입력받기
  if (limit === input.length - 1) rl.close();
}).on("close", () => {
  input = input.filter((v, i) => i !== 0);

  input.forEach(v => {
    output = v.split(" ");
    console.log(+output[0] + +output[1]);
  });

  process.exit();
});

3. 8393번 - 합

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

let input = null;
let output = null;

rl.on("line", line => {
  input = +line;
  output = Array(input)
    .fill()
    .map((v, i) => i + 1);

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

4. 15552번 - 빠른 A+B

매번 출력 X, 한번에 모아서 출력 O

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

let input = [];
let output = null;
let answer = "";
let limit = 999;

rl.on("line", line => {
  input.push(line);
  limit = +input[0];

  // 최초 입력한 값만큼만 입력받기
  if (limit === input.length - 1) rl.close();
}).on("close", () => {
  input = input.filter((v, i) => i !== 0);

  input.forEach(v => {
    output = v.split(" ");
    answer += +output[0] + +output[1] + "\n";
  });

  console.log(answer);

  process.exit();
});

5. 2741번 - N 찍기

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

let input = null;
let output = null;
let answer = "";

rl.on("line", line => {
  input = +line;
  output = Array(input)
    .fill()
    .map((v, i) => i + 1);

  rl.close();
}).on("close", () => {
  output.forEach(v => (answer += `${v}\n`));

  console.log(answer);

  process.exit();
});

6. 2742번 - 기찍 N

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

let input = null;
let output = null;
let answer = "";

rl.on("line", line => {
  input = +line;
  output = Array(input)
    .fill()
    .map((v, i) => i + 1)
    .reverse();

  rl.close();
}).on("close", () => {
  output.forEach(v => (answer += `${v}\n`));

  console.log(answer);

  process.exit();
});

7. 11021번 - A+B-7

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

let input = [];
let output = null;
let answer = "";
let limit = 999;

rl.on("line", line => {
  input.push(line);
  limit = +input[0];

  // 최초 입력한 값만큼만 입력받기
  if (limit === input.length - 1) rl.close();
}).on("close", () => {
  input = input.filter((v, i) => i !== 0);

  input.forEach((v, i) => {
    output = v.split(" ");
    answer += `Case #${i + 1}: ${+output[0] + +output[1]}\n`;
  });

  console.log(answer);

  process.exit();
});

8. 11022번 - A+B-8

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

let input = [];
let output = null;
let answer = "";
let limit = 999;

rl.on("line", line => {
  input.push(line);
  limit = +input[0];

  // 최초 입력한 값만큼만 입력받기
  if (limit === input.length - 1) rl.close();
}).on("close", () => {
  input = input.filter((v, i) => i !== 0);

  input.forEach((v, i) => {
    output = v.split(" ");
    answer += `Case #${i + 1}: ${output[0]} + ${output[1]} = ${+output[0] + +output[1]}\n`;
  });

  console.log(answer);

  process.exit();
});

9. 2438번 - 별 찍기 - 1

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

let input = [];
let answer = "";

rl.on("line", line => {
  input = +line;
  rl.close();
}).on("close", () => {
  for (let i = 0; i < input; i++) {
    for (let j = 0; j <= i; j++) {
      answer += `*`;
    }
    answer += `\n`;
  }
  console.log(answer);
  process.exit();
});

10. 2439번 - 별 찍기 - 2

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

let input = [];
let answer = "";

rl.on("line", line => {
  input = +line;
  rl.close();
}).on("close", () => {
  for (let i = 0; i < input; i++) {
    for (let j = input; j > i + 1; j--) {
      answer += ` `;
    }
    for (let k = 0; k <= i; k++) {
      answer += `*`;
    }
    answer += `\n`;
  }
  console.log(answer);
  process.exit();
});

11. 10871번 - X보다 작은 수

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

let input = [];
let answer = "";
let limit = 999;

rl.on("line", line => {
  input.push(line.split(" "));
  limit = +input[0][0];

  // 최초 입력한 값만큼만 입력받기
  if (input.length > 1 && limit === input[1].length) rl.close();
}).on("close", () => {
  const number = +input[0][1];
  input[1].filter(v => +v < number).forEach(v => (answer += `${v} `));

  console.log(answer);
  process.exit();
});

0개의 댓글