Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://zero.p2p.shpp.me/tasks/3_5_christmas_tree.html
- // row - рядок виводу
- // column - колонка виводу;
- let height = +prompt("Який розмір ялинки?");//висота
- let width = 2 * height + 1;// ширина
- let star = '*';
- let space = ' ';
- for (let row = 0; row <= height; row++) {
- if (height == 0) break;
- let stars_count = 1 + 2 * row;//кількість зірок
- if (row == height) {
- stars_count = 1;
- }
- let spaces_count = width - stars_count;
- for (let i = 0; i < spaces_count / 2; i++) {
- console.put(space);
- }
- for (let i = 0; i < stars_count; i++) {
- console.put(star);
- }
- for (let i = 0; i < spaces_count / 2; i++) {
- console.put(space);
- }
- console.log();
- }
Advertisement
Add Comment
Please, Sign In to add comment