1330번: 두 수 비교하기
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let inputString;
const onInput = (input) => inputString = input;
const onClose = () => {
const [num1, num2] = inputString.split(" ");
if(Number(num1) > Number(num2)) {
console.log(">");
} else if (Number(num1) < Number(num2)) {
console.log("<");
} else if (Number(num1) === Number(num2)) {
console.log("==");
}
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);
9498번: 시험 성적
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let score = 0;
const onInput = (input) => score = Number(input);
const onClose = () => {
if(score >= 90) {
console.log('A');
} else if(score >= 80) {
console.log('B');
} else if(score >= 70) {
console.log('C');
} else if(score >= 60) {
console.log('D');
} else {
console.log('F');
}
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);
2753번: 윤년
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let year = 0;
const onInput = (input) => year = Number(input);
const onClose = () => {
if(year % 400 === 0)
{
console.log(1);
} else if((year % 4 === 0) && (year % 100 !== 0)) {
console.log(1);
} else {
console.log(0);
}
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);
14681번: 사분면 고르기
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const array = [];
const onInput = (input) => array.push(Number(input));
const onClose = () => {
const [num1, num2] = array;
if (num1 > 0 && num2 > 0) {
console.log(1);
} else if (num1 < 0 && num2 > 0) {
console.log(2);
} else if (num1 < 0 && num2 < 0) {
console.log(3);
} else if (num1 > 0 && num2 < 0) {
console.log(4);
}
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);
2884번: 알람 시계
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let time;
const onInput = (input) => time = input;
const onClose = () => {
let [hour, minute] = time.split(" ");
hour = Number(hour);
minute = Number(minute);
minute = minute - 45;
if(minute < 0) {
hour -= 1;
if(hour < 0) {
hour += 24;
}
minute += 60 ;
}
console.log(`${hour} ${minute}`);
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);