Created
September 29, 2018 22:48
-
-
Save flymio/91d4b4df957ca75d0f3cdc8beeae4abf to your computer and use it in GitHub Desktop.
solutions for https://www.hackerrank.com/challenges/staircase/
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
Искал перловое 'STR' x SCALAR, но не помнил название функции, в итоге в солюшинах нашел str_repeat |
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
<?php | |
// Complete the staircase function below. | |
function staircase($n) { | |
for($i=0;$i<=$n-1;$i++){ | |
for($j=$n-$i-1;$j>0;$j--){ | |
echo " "; | |
} | |
for($j=$n-1;$j>$n-$i-2;$j--){ | |
echo "#"; | |
} | |
echo "\n"; | |
} | |
} | |
$stdin = fopen("php://stdin", "r"); | |
fscanf($stdin, "%d\n", $n); | |
staircase($n); | |
fclose($stdin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment