Last active
December 22, 2018 08:35
-
-
Save BAHC/b0d340bb7fb59f2ba3bb9654a64fa436 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Привет в 2019 из книги 2008 года | |
* Андрей Богатырев. Руководство полного идиота | |
* по программированию (на языке Си) | |
* http://lib.ru/CTOTOR/starterkit.txt | |
*/ | |
define("LINES", 19); | |
function getStar() | |
{ | |
$stars = '*❆❅❈✼✻✵❂✱✲☽☾✎☯♕✈☼'; | |
return mb_substr($stars, mt_rand(0, mb_strlen($stars)-1), 1); | |
} | |
function drawOneLine($nspaces, $nstars) { | |
/* $i; номер печатаемой звездочки, счетчик | |
он же - номер печатаемого пробела */ | |
for($i=0;$i<$nspaces;$i++) | |
{ | |
echo ' '; | |
} | |
for($i=0;$i<$nstars;$i++) | |
{ | |
echo (1==$nstars)? '✩': | |
((rand(0,$nspaces+LINES/3)==0)? getStar(): '*'); | |
} | |
echo PHP_EOL; | |
} | |
for($nline=1; $nline <= LINES; $nline++) | |
{ | |
drawOneLine( | |
LINES - $nline, /* число пробелов --> nspaces */ | |
$nline*2 - 1 /* число звездочек --> nstars */ | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment