ybakun

Задача Ялинка 2021/07/12 Yuliia Bakun

Jul 12th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Задача. Вивести ялинку на екран
  2. // https://zero.p2p.shpp.me/tasks/3_5_christmas_tree.html
  3.  
  4. let treeSize = +prompt("Вкажіть розмір ялинки");
  5. let i = 0;
  6. while (i <= treeSize) {
  7.     for (let n = treeSize; n > i; n--) {
  8.         console.put(" ");
  9.     }
  10.     for (let j = 0; j < i; j++) {
  11.         console.put("*");
  12.     }
  13.     for (let k = 1; k < i; k++) {
  14.         console.put("*");
  15.     }
  16.     i++;
  17.     console.log();
  18. }
  19. let spaces = 0;
  20. while (spaces < treeSize - 1) {
  21.     console.put(" ");
  22.     spaces++;
  23. }
  24. console.log("*");
Advertisement
Add Comment
Please, Sign In to add comment