Skip to content

Instantly share code, notes, and snippets.

@Harvie
Last active December 31, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harvie/8043147 to your computer and use it in GitHub Desktop.
Save Harvie/8043147 to your computer and use it in GitHub Desktop.
<?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