Skip to content

Commit

Permalink
conditional_statements
Browse files Browse the repository at this point in the history
  • Loading branch information
HA-SEUNG-JEONG committed May 14, 2022
1 parent 30dd9a0 commit 12db381
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 6 deletions.
15 changes: 15 additions & 0 deletions haseung/Conditional_Statements/02_1330.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오.

const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split(" ");

const a = parseInt(inputs[0], 10);
const b = parseInt(inputs[1], 10);

if (a === b) {
console.log("==");
} else if (a > b) {
console.log(">");
} else {
console.log("<");
}
15 changes: 15 additions & 0 deletions haseung/Conditional_Statements/02_14681.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split("\n");

const a = parseInt(inputs[0], 10);
const b = parseInt(inputs[1], 10);

if (a > 0 && b > 0) {
console.log("1");
} else if (a < 0 && b > 0) {
console.log("2");
} else if (a < 0 && b < 0) {
console.log("3");
} else {
console.log("4");
}
29 changes: 29 additions & 0 deletions haseung/Conditional_Statements/02_2480.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs");
const inputs = fs
.readFileSync(0, "utf-8")
.toString()
.trim()
.split(" ")
.map(Number);

const [firstNumber, secondNumber, lastNumber] = [
inputs[0],
inputs[1],
inputs[2],
];

const answer = (a, b, c) => {
if (a === b && a === c && b === c) return console.log(10000 + a * 1000);

if (a !== b || a !== c || b !== c) {
if (a === b || a === c) return console.log(1000 + a * 100);
if (b === c) return console.log(1000 + b * 100);
}

if (a !== b && a !== c && b !== c) {
const sort = [a, b, c].sort();
return console.log(sort.pop() * 100);
}
};

answer(firstNumber, secondNumber, lastNumber);
25 changes: 25 additions & 0 deletions haseung/Conditional_Statements/02_2525.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// KOI 전자에서는 건강에 좋고 맛있는 훈제오리구이 요리를 간편하게 만드는 인공지능 오븐을 개발하려고 한다. 인공지능 오븐을 사용하는 방법은 적당한 양의 오리 훈제 재료를 인공지능 오븐에 넣으면 된다. 그러면 인공지능 오븐은 오븐구이가 끝나는 시간을 분 단위로 자동적으로 계산한다.

// 또한, KOI 전자의 인공지능 오븐 앞면에는 사용자에게 훈제오리구이 요리가 끝나는 시각을 알려 주는 디지털 시계가 있다.

// 훈제오리구이를 시작하는 시각과 오븐구이를 하는 데 필요한 시간이 분단위로 주어졌을 때, 오븐구이가 끝나는 시각을 계산하는 프로그램을 작성하시오.

const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split("\n");

let currentHour = parseInt(inputs[0].split(" ")[0]);
let currentMinute = parseInt(inputs[0].split(" ")[1]);
let addedTime = parseInt(inputs[1]);

solution(currentHour, currentMinute, addedTime);

function solution(doneHour, doneMinute, cookedTime) {
doneMinute += cookedTime;

while (doneMinute >= 60) {
doneMinute -= 60;
doneHour += 1;
}
doneHour %= 24;
console.log(doneHour, doneMinute);
}
10 changes: 10 additions & 0 deletions haseung/Conditional_Statements/02_2753.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split(" ");

const year = parseInt(inputs[0], 10);

if (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)) {
console.log("1");
} else {
console.log("0");
}
25 changes: 25 additions & 0 deletions haseung/Conditional_Statements/02_2884.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다.

// 상근이는 모든 방법을 동원해보았지만, 조금만 더 자려는 마음은 그 어떤 것도 없앨 수가 없었다.

// 이런 상근이를 불쌍하게 보던, 창영이는 자신이 사용하는 방법을 추천해 주었다.

// 바로 "45분 일찍 알람 설정하기"이다.

// 이 방법은 단순하다. 원래 설정되어 있는 알람을 45분 앞서는 시간으로 바꾸는 것이다. 어차피 알람 소리를 들으면, 알람을 끄고 조금 더 잘 것이기 때문이다. 이 방법을 사용하면, 매일 아침 더 잤다는 기분을 느낄 수 있고, 학교도 지각하지 않게 된다.

// 현재 상근이가 설정한 알람 시각이 주어졌을 때, 창영이의 방법을 사용한다면, 이를 언제로 고쳐야 하는지 구하는 프로그램을 작성하시오.

const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split(" ");

const a = parseInt(inputs[0], 10);
const b = parseInt(inputs[1], 10);

if (b > 44) {
console.log(a, b - 45);
} else if (b < 45 && a > 0) {
console.log(a - 1, b + 15);
} else {
console.log(23, b + 15);
}
16 changes: 16 additions & 0 deletions haseung/Conditional_Statements/02_9498.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require("fs");
const inputs = fs.readFileSync(0, "utf-8").toString().split(" ");

const a = parseInt(inputs[0], 10);

if (a >= 90 && a <= 100) {
console.log("A");
} else if (a >= 80 && a <= 89) {
console.log("B");
} else if (a >= 70 && a <= 79) {
console.log("C");
} else if (a >= 60 && a <= 69) {
console.log("D");
} else {
console.log("F");
}
19 changes: 13 additions & 6 deletions haseung/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

## 백준

## 01\_입출력과 사칙연산

| 번호 | 백준 번호 | 분류 | 풀이 날짜 | 문제 | 풀이 |
| :--: | :-------: | :------------------: | :--------: | :-----------------------------------: | :-----------------------: |
| 1 | 2577 | 출력 | 12-05-2022 | Hello World | [Javascript](01_2577.js) |
Expand All @@ -33,9 +35,14 @@
| 12 | 1000 | 수학, 구현, 사칙연산 | 12-05-2022 | 나머지 | [Javascript](01_10430.js) |
| 13 | 1000 | 수학, 구현, 사칙연산 | 12-05-2022 | 곱셈 | [Javascript](01_2588.js) |

<br>
<br>
<br>
<br>

##
## 02\_조건문

| 번호 | 백준 번호 | 분류 | 풀이 날짜 | 문제 | 풀이 |
| :--: | :-------: | :------------------: | :--------: | :------------: | :-----------------------: |
| 1 | 1330 | 수학, 구현, 사칙연산 | 14-04-2022 | 두 수 비교하기 | [Javascript](01_1330.js) |
| 2 | 9498 | 구현 | 14-04-2022 | 시험 성적 | [Javascript](02_9498.js) |
| 3 | 2753 | 수학, 구현 | 14-04-2022 | 윤년 | [Javascript](03_2753.js) |
| 4 | 14681 | 수학, 구현, 기하학 | 14-04-2022 | 사분면 고르기 | [Javascript](04_14681.js) |
| 5 | 2884 | 수학, 사칙연산 | 14-04-2022 | 알람 시계 | [Javascript](05_2884.js) |
| 6 | 2525 | 수학, 사칙연산 | 14-04-2022 | 오븐 시계 | [Javascript](06_2525.js) |
| 7 | 2480 | 수학, 사칙연산 | 14-04-2022 | 주사위 세개 | [Javascript](07_2480.js) |

0 comments on commit 12db381

Please sign in to comment.