Skip to content

Commit

Permalink
Merge pull request #208 from KTsarenko/master
Browse files Browse the repository at this point in the history
hw2-v2
  • Loading branch information
VitaliiHurin authored Nov 10, 2018
2 parents 545fe08 + df845fa commit 9792086
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions homeworks/konstantin.tsarenko_KTsarenko/homework_2/hw2-1_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const readline = require('readline');

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

rl.question('Ведите высоту пирамиды: ', (answer) => {
if (!Number.isNaN(Math.round(answer))) {
const height = parseInt(answer, 10) + 2;
const space = ' ';
const symbol = '#';
let i = 2;
for (i; i < height; i++) {
const spaceRep = space.repeat(height - i);
const symbolRep = symbol.repeat(i);
const strResult = spaceRep + symbolRep + symbolRep + spaceRep;
console.log(strResult);
}
rl.close();
} else {
console.log('Ошибка ввода.');
rl.close();
}
});
25 changes: 25 additions & 0 deletions homeworks/konstantin.tsarenko_KTsarenko/homework_2/hw2-2_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const readline = require('readline');

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

rl.question('Ведите минимальное значение: ', (answer) => {
const minNum = parseInt(answer, 10);
rl.question('Ведите максимальное значение: ', (answer2) => {
if (!Number.isNaN(Math.round(answer2)) && !Number.isNaN(Math.round(answer))) {
const maxNum = parseInt(answer2, 10);
for (let i = minNum; i <= maxNum; i++) {
const num = i.toString();
if (num === num.split('').reverse().join('')) {
console.log(num);
}
}
rl.close();
} else {
console.log('Ошибка ввода.');
rl.close();
}
});
});

0 comments on commit 9792086

Please sign in to comment.