Advertisement
Guest User

Untitled

a guest
May 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script>
  4. function z1()
  5. {
  6. tab=[];
  7. for (i=0; i<10;i++)
  8. tab[i]=Math.round(Math.random()*30+1);
  9. document.getElementById("wyswietl").innerHTML=tab;
  10. document.getElementById("wyswietl_pierwszy").innerHTML=tab[0];
  11. document.getElementById("wyswietl_ostatni").innerHTML=tab[9];
  12. }
  13.  
  14. function z2()
  15. {
  16. tab=[];
  17. for (i=0; i<10;i++)
  18. tab[i]=Math.round(Math.random()*30+1);
  19. document.getElementById("w3").innerHTML = Math.min.apply(Math,tab) + "<br>";
  20. document.getElementById("w4").innerHTML += Math.max.apply(Math,tab);
  21. }
  22. </script>
  23. <body>
  24. <button onclick="z1()">Wyswietl</button>
  25. <p id="wyswietl"></p>
  26. <button onclick="z1()">Wyświetl pierwszy</button>
  27. <p id="wyswietl_pierwszy"></p>
  28. <button onclick="z1()">Wyświetl ostatni</button>
  29. <p id="wyswietl_ostatni"></p>
  30. <button onclick="z2()">Element minimalny</button>
  31. <p id="w3"></p>
  32. <button onclick="z2()">Element maksymalny</button>
  33. <p id="w4"></p>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement