NastySwipy

Exam - 16 December 2017 - 05. Christmas Toy

Feb 25th, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2. $num = intval(readline());
  3. echo str_repeat("-", $num * 2) . str_repeat("*", $num) . str_repeat("-", $num * 2) . "\n";
  4. for ($i = 1, $j = 2; $i <= $num / 2; $i++, $j += 2) {
  5.     echo str_repeat("-", 2 * $num - $j) . str_repeat("*", $i)
  6.     . str_repeat("&", $num + $j) . str_repeat("*", $i) . str_repeat("-", 2 * $num - $j) . "\n";
  7. }
  8. for ($i = 1, $j = 0; $i <= $num / 2; $i++, $j += 2) {
  9.     $wide = 5 * $num;
  10.     $dash = $num - $i;
  11.     echo str_repeat("-", $dash) . "**" . str_repeat("~", (($wide - (2 * $dash)) - 4))
  12.     . "**" . str_repeat("-", $dash) . "\n";
  13. }
  14. echo str_repeat("-", ceil($num / 2)) . "*" . str_repeat("|", ($wide - 2) - (2 * ceil($num / 2)))
  15.  . "*" . str_repeat("-", ceil($num / 2)) . "\n";
  16. for ($i = 0; $i < $num / 2; $i++) {
  17.     echo str_repeat("-", $num / 2 + $i) . "**" . str_repeat("~", $wide - (2 * ($num / 2 + $i)) - 4)
  18.     . "**" . str_repeat("-", $num / 2 + $i) . "\n";
  19. }
  20. for ($i = 0, $j = 0; $i < floor($num / 2); $i++, $j += 2) {
  21.     echo str_repeat("-", $num + $j) . str_repeat("*", $num / 2 - $i) . str_repeat("&", 2 * $num - $j)
  22.     . str_repeat("*", $num / 2 - $i) . str_repeat("-", $num + $j) . "\n";
  23. }
  24. echo str_repeat("-", $num * 2) . str_repeat("*", $num) . str_repeat("-", $num * 2) . "\n";
Advertisement
Add Comment
Please, Sign In to add comment