Created
April 25, 2024 10:18
-
-
Save Filimon4/1f413022d7d7e24c3e50d5698f035aa4 to your computer and use it in GitHub Desktop.
задача под звёздочкой
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function square(bigX: number, bigY: number, smlX: number, smlY: number) { | |
const innerSquare = () => { | |
let square: string = `` | |
let part: string = `|${Array(smlX).fill("*").join('')}|` | |
for (let h: number = 0; h < smlY; h++) { | |
for (let bigW: number = 0; bigW < bigX; bigW++) { | |
process.stdout.write(part) | |
process.stdout.write("\t") | |
} | |
process.stdout.write("\n") | |
} | |
process.stdout.write("\n"); | |
} | |
for (let h: number = 0; h < bigY; h++) { | |
innerSquare() | |
} | |
} | |
square(4,4,4,4) |
Сделано не совсем верно. Твоя функция всегда рисует 4 на 4 и заполняет ее 16 элементами.
Нужно продумать так что бы оно вмещало только столько квадратов, сколько у нее ширина.
Пример:
Если на вход подается большой квадрат 4x4, а маленький 3x3, то в большом поместиться только 1 маленьких.
| * * * |
| * * * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Я добавил разделение между объектами