Created
October 28, 2018 07:57
-
-
Save benznest/699fe927d44e622ef1e0de3b9408a2cc to your computer and use it in GitHub Desktop.
การบ้านปริ้นสามเหลี่ยม php
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 | |
$rows = 10; | |
// Rectangle Normal | |
for($i=0; $i<$rows; $i++){ | |
for($j=0; $j<$rows; $j++){ | |
echo"O"; | |
} | |
echo"<br>"; | |
} | |
echo"<br>"; | |
// Triangle A | |
for($i=0; $i<$rows; $i++){ | |
for($j=0; $j<$i; $j++){ | |
echo"O"; | |
} | |
echo"<br>"; | |
} | |
echo"<br>"; | |
// Triangle B | |
for($i=0; $i<$rows; $i++){ | |
for($j=$i; $j<$rows; $j++){ | |
echo"O"; | |
} | |
echo"<br>"; | |
} | |
echo"<br>"; | |
// Triangle C | |
for($i=0; $i<$rows; $i++){ | |
for($j=$rows - $i ; $j<$rows; $j++){ | |
echo"<font color='white'>O</font>"; | |
} | |
for($j=$i; $j<$rows; $j++){ | |
echo"O"; | |
} | |
echo"<br>"; | |
} | |
echo"<br>"; | |
// Triangle D | |
for($i=0; $i<$rows; $i++){ | |
for($j=$i ; $j<$rows; $j++){ | |
echo"<font color='white'>O</font>"; | |
} | |
for($j=$rows - $i; $j<$rows; $j++){ | |
echo"O"; | |
} | |
echo"<br>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment