Jak za pomocą kropki i # zakodować serce w js?

0

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]);

0

Wydaje mi się, że ten problem nie ma sensu. Mógłbyś narysować serce podając wysokość i szerokość. Wtedy byś zdefiniował, że stosunek odpowiednich długości i bez problemu narysował serce.

Mogę się mylić, ale wydaje mi się, że te cztery wartości nie wystarczą, żeby narysować takie serce.

0

Pierwszy argument to szerokość jednego glifu.

Więc możesz podzielić serce na połowy, od góry do dołu, i zająć się myśleniem nad tylko jedną z nich – drugą narysujesz już lustrzanie.

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.

Tego nie rozumiem. O które "części" serca chodzi?

1 użytkowników online, w tym zalogowanych: 0, gości: 1