Hej potrzebuję pomocy przy takim zadaniu. Program przyjmuje 4 liczby całkowite dodatnie (w argv).Pierwszy argument to szerokość jednego glifu. Drugi argument to wysokość glifów części górnej. Trzeci argument to wysokość glifów części środkowej. Wreszcie, czwarty argument to wysokość glifów części dolnej. Prawidłowe znaki to kropka, znak nowej linii i płotek #. Chciałbym uzyskac efekt, jak na załączonym obrazku. Zacząłem robić w ten sposób(utworzenie jednej linijki), ale chyba nie o to chodzi. Ktoś coś podpowie?
function drawHeart(arg1, arg2, arg3, arg4) {
for(var i = 0; i < arg1; i++) {
var dot = "";
for(var j = 0; j <=8; j++) {
dot += ".";}
for(var k = 0; k < arg2; k++) {
var hash = "";
for(var l = 0; l <=4; l++) {
hash += "#";}
for(var i1 = 0; i1 < arg3; i1++) {
var dot1 = "";
for(var j1 = 0; j1 <=12; j1++) {
dot1 += ".";}
console.log(dot + hash + dot1 + hash + dot);
}
}
}
}
drawHeart(1,1,1,1)
albo tak, tylko raczej jest to średnie;)
var heart = [
["top", "........", "####"],
["top1", "....", "############"],
["top2", "####################################"],
["middle", "########" ]
];
console.log(heart[0][1] + heart[0][2] + heart[0][1] + heart[0][2] + heart[0][1]);
console.log(heart[1][1] + heart[1][2] + heart[1][1] + heart[1][2] + heart[1][1]);
console.log(heart[2][1]);
console.log(heart[2][1]);
console.log(heart[2][1]);
console.log(heart[3][1] + heart[1][1] + heart[1][2] + heart[1][1] + heart[3][1]);
console.log(heart[3][1] + heart[0][1] + heart[0][2] + heart[0][1] + heart[3][1]);
console.log(heart[3][1] + heart[0][1] + heart[0][1] + heart[1][1] + heart[3][1]);
console.log(heart[1][2] + heart[0][1] + heart[1][1] + heart[1][2]);
console.log(heart[1][2] + heart[0][2] + heart[1][1] + heart[1][2] + heart[0][2]);
console.log(heart[2][1]);
console.log(heart[1][1] + heart[1][2] + heart[1][2] + heart[0][2] + heart[1][1]);
console.log(heart[0][1] + heart[1][2] + heart[3][1] + heart[0][1]);
console.log(heart[0][1] + heart[1][1] + heart[1][2] + heart[0][1] + heart[1][1]);
console.log(heart[0][1] + heart[1][1] + heart[1][1] + heart[0][2] + heart[0][1] + heart[1][1] + heart[1][1]);