Created
April 6, 2016 03:21
-
-
Save ad3n/158fa7cf9c2450df5a96d683f6d078af to your computer and use it in GitHub Desktop.
[PHPID QUIZ] Segitiga
This file contains 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 | |
$a = '.'; | |
$space = ' '; | |
$ulang = 20; | |
for ($i = 1; $i < $ulang; $i+= 2) { | |
for ($j = ($ulang-$i)/2; $j >= 0; $j--) { | |
echo $space; | |
} | |
for ($k = 0; $k < $i; $k++) { | |
echo $a; | |
} | |
echo PHP_EOL; | |
} | |
for ($l = 1; $l < $ulang; $l += 2) { | |
for ($m = 0; $m < $l/2; $m++) { | |
echo $space; | |
} | |
for ($n = ($ulang - $l); $n > 0; $n--) { | |
echo $a; | |
} | |
echo PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment