Last active
December 31, 2015 20:49
-
-
Save Harvie/8043147 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 | |
function polarx($u,$v){ | |
return ($v*cos(deg2rad($u))); | |
} | |
function polary($u,$v){ | |
return ($v*sin(deg2rad($u))); | |
} | |
$x=23; | |
$y=23; | |
//tady sestavujeme ciferník | |
$cif=array(); | |
for($i=0;$i<$x;$i=$i+1) { | |
for($j=0;$j<$y;$j=$j+1) { | |
if (false){ | |
$cif[$j][$i]="*"; | |
} else { | |
$cif[$j][$i]=" "; | |
} | |
} | |
} | |
$cif[$y/2][$x/2]="."; | |
for($h=0;$h<12;$h=$h+3){ | |
$uhel=-($h*(360/12)); | |
$px=round (polarx($uhel,10))+$x/2; | |
$py=round(polary($uhel,10))+$y/2; | |
$cif[$py][$px]="$h"; | |
} | |
//tady vykreslujeme ciferník | |
for($i=0;$i<$x;$i=$i+1) { | |
for($j=0;$j<$y;$j=$j+1) { | |
if (($i==$y-$j-1) || ($i==3)){ | |
echo($cif[$j][$i]); | |
} else { | |
echo($cif[$j][$i]); | |
} | |
} | |
echo("\n"); | |
} | |
/* Vystup: | |
6 | |
3 . 9 | |
0 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment