Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ira Cherednichenko
- //https://zero.p2p.shpp.me/tasks/3_4_triangle.html
- //while
- //1
- let squareSize = +prompt("Вкажіть розмір трикутника");
- let squareText1 = "";
- let i = 0;
- while (i < squareSize) {
- i++;
- let j = 0;
- while (j < i) {
- j++;
- squareText1 += "*";
- }
- squareText1 += "\n";
- }
- console.log(squareText1);
- //2
- let squareSize1 = +prompt("Вкажіть розмір трикутника");
- let squareText1 = "";
- let i = 0;
- while (i < squareSize1) {
- i++;
- let j = squareSize1;
- while (j >= i) {
- j--;
- squareText1 += "*";
- }
- squareText1 += "\n";
- }
- console.log(squareText1);
- //3
- let squareSize2 = +prompt("Вкажіть розмір трикутника");
- let squareText2 = "";
- let i = 0;
- while (i < squareSize2) {
- i++;
- let j = squareSize2;
- while (j > i) {
- j--;
- if (i >= 0) {
- squareText2 += " ";
- }
- }
- let k = 0;
- while (k < i) {
- k++;
- squareText2 += "*";
- }
- squareText2 += "\n";
- }
- console.log(squareText2);
- //4
- let squareSize3 = +prompt("Вкажіть розмір трикутника");
- let squareText3 = "";
- let i = 0;
- while (i < squareSize3) {
- i++;
- let j = 0;
- while (j <= i) {
- j++;
- if (i > 0) {
- squareText3 += " ";
- }
- }
- let k = squareSize3;
- while (k >= i) {
- k--;
- squareText3 += "*";
- }
- squareText3 += "\n";
- }
- console.log(squareText3);
Advertisement
Add Comment
Please, Sign In to add comment