add start lesson 1_4
This commit is contained in:
parent
3071bb4746
commit
5bef125273
23
src/index.ts
23
src/index.ts
|
@ -1,17 +1,26 @@
|
|||
//Обучение ЦИКЛАМ
|
||||
|
||||
//lesson 1.4 X-MAS TREE
|
||||
|
||||
function DrawLine(count: number, countP: number){ //рисуем треугольник из звездочек
|
||||
const minimalString = '*';
|
||||
const minimalP = ' ';
|
||||
|
||||
let result = minimalP.repeat(countP) + minimalString.repeat(count) //с начала рисуем пробелы (countP) а потом зведочки
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
function DrawTriangle(height: number) {
|
||||
for(let index = 1; index <= height; ){
|
||||
DrawLine(index * 2 - 1, height - index);
|
||||
DrawLine(index * 2 - 1, height - index); // вызываем функцию DrawLine
|
||||
index = index +1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//DrawTriangle(3); // простой вывод функции на экран
|
||||
//DrawTriangle(1); // простой вывод функции на экран
|
||||
|
||||
for(let index = 1; index <= 5;){
|
||||
for(let index = 1; index <= 2;){ // index <= 2 регулируем число елочек
|
||||
DrawTriangle(index);
|
||||
index = index +1;
|
||||
}
|
||||
|
@ -21,13 +30,7 @@ for(let index = 1; index <= 5;){
|
|||
|
||||
//lesson 1.3 ANOTHER TRIANGLE
|
||||
|
||||
function DrawLine(count: number, countP: number){
|
||||
const minimalString = '*';
|
||||
const minimalP = ' ';
|
||||
|
||||
let result = minimalP.repeat(countP) + minimalString.repeat(count) //с начала рисуем пробелы (countP) а потом зведочки
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/*let chisloN: number = 5; //эмуляция вводу а с клавиатуры числа N
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue