Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $num = intval(readline());
- echo str_repeat("-", ($num - 1) / 2) . str_repeat("*", $num & 1 ? 1 : 2) . str_repeat("-", ($num - 1) / 2) . "\n";
- for ($i = 1, $j = 0; $i < $num / 2; $i++, $j += 2) {
- echo str_repeat("-", (($num - 1) / 2) - $i) . "*" . str_repeat("-", ($num & 1 ? 1 : 2) + $j) . "*" . str_repeat("-", (($num - 1) / 2) - $i) . "\n";
- }
- for ($i = 1, $j = 0; $i <= ($num - 3) / 2; $i++, $j += 2) {
- echo str_repeat("-", $i) . "*" . str_repeat("-", round($num - 4) - $j) . "*" . str_repeat("-", $i) . "\n";
- }
- if ($num != 1 && $num != 2) {
- echo str_repeat("-", ($num - 1) / 2) . str_repeat("*", $num & 1 ? 1 : 2) . str_repeat("-", ($num - 1) / 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment