KrasimiraGeorgieva

05. Crown, Programming Basics Exam - 7 May 2017

Feb 24th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.  
  3. // Пета задача от изпит "Програмиране за начинаещи" – 7 май 2017
  4.  
  5. $n = intval(readline());
  6. $row = (2 * $n) - 1;
  7.  
  8. printf("@%s@%s@\n", (str_repeat(' ', $n - 2)), (str_repeat(' ', $n - 2)));
  9. printf("**%s*%s**\n", str_repeat(' ', $n-3), str_repeat(' ', $n-3));
  10.  
  11. $a = 0;
  12. $b = 1;
  13. for ($i = 1; $i < floor($n / 2) - 1; $i++) {
  14.     printf("*%s*%s*%s*%s*%s*\n",
  15.         (str_repeat('.', $i)),
  16.         (str_repeat(' ', floor(($row - 6)/2) - 1 + $a)),
  17.         (str_repeat('.', $b)),
  18.         (str_repeat(' ', floor(($row-6)/2) - 1 + $a)),
  19.         (str_repeat('.', $i)));
  20.  
  21.     $a -= 2;
  22.     $b += 2;
  23. }
  24.  
  25. printf("*%s*%s*%s*\n",
  26.         str_repeat('.',floor($n/2)-1),
  27.         str_repeat('.',$n-3),
  28.         str_repeat('.',floor($n/2)-1));
  29.  
  30. printf("*%s%s.%s%s*\n",
  31.         str_repeat('.', floor($n / 2)),
  32.         str_repeat('*', ceil($n / 2) - 2),
  33.         str_repeat('*', ceil($n / 2) - 2),
  34.         str_repeat('.', floor($n / 2)));
  35.  
  36. echo str_repeat('*', $row) . "\n";
  37. echo str_repeat('*', $row);
Advertisement
Add Comment
Please, Sign In to add comment