<?php
for ($row = 1; $row <= $_POST["number"]; $row++)
{
for ($col = 1; $col <= ($row >= ($_POST["number"]/2) ? ($_POST["number"]+1)- $row : $row); $col++)
{
echo '* ';
}
echo "<br>";
}
print(json_encode(count($row)));
?>
the question is to print the pattern and also the total number of stars in each row. i tried degugging my self but if i change the condition and only for some inputs the answer is correct.
Aucun commentaire:
Enregistrer un commentaire