HADANIE CISEL (2)

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

098
p098.html / p098.zip
Hadanie cisel v udanom rozsahu
1656b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<html> <head> <title> JavaScript DESTINATION - P098 </title> <script language="JavaScript"> <!-- var my_no,count; function load() { window.defaultStatus="Hadanie cisel"; document.game.help.value="Prosim nastavte rozsah hadanych cisel a stlacte tlacitko Start."; document.game.from.focus(); } function rnd(scale) { var dd=new Date(); return((Math.round(Math.abs(Math.sin(dd.getTime()))*8.71*scale)%scale)); } function range() { var to=1+1*document.game.to.value; count=0; my_no=rnd(to); while(my_no<document.game.from.value) { my_no=rnd(to); } document.game.help.value="Teraz hadajte cislo a stlacte tlacitko Hadaj."; } function guess() { var no=document.game.number.value; count++; if(no<my_no) document.game.help.value="Moje cislo je vacsie nez "+no+"."; else if(no>my_no) document.game.help.value="Moje cislo je mensie nez "+no+"."; else alert("Na "+count+" pokusov si uhadol cislo"); } // --> </script> </head> <body onload="load()" onunload="window.defaultStatus=''"> <center> <form name=game> <table border=3> <tr><td align=center colspan=2>Rozsah cisel:</td> <td align=center rowspan=2><input type=button value=" Start " onclick="range()"></td></tr> <tr><td align=center>Od:<br><input type=text name=from size=10></td> <td align=center>Do:<br><input type=text name=to size=10></td></tr> <tr><td></td></tr> <tr><td align=center colspan=3><input type=text name=help size=70></td></tr> <tr><td></td></tr> <tr><td align=right colspan=3><input type=text name=number size=10><input type=button value=" Hadaj " onclick="guess()"></td></tr> </table> </form> </center> </body> </html>
[ Navrat / BACK ]