This is a staircase of size :4 # ## ### ####
// Complete the staircase function below.
function staircase($n)
{
$max = $n - 1;
for ($i = 0;$i < $n;$i++)
{
for ($j = 0;$j < ($max - $i);$j++)
{
echo " ";
}
for ($k = 0;$k <= $i;$k++)
{
echo "#";
}
echo "\n";
}
}
$stdin = fopen("php://stdin", "r");
fscanf($stdin, "%d\n", $n);
staircase($n);
fclose($stdin);
0 Response to "Staircase"
Post a Comment