Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10.  
  11. <script>
  12. let l = 1;
  13. let p = 100;
  14. let srednia=Math.floor((p+l)/2);
  15.  
  16.  
  17. var szukana=prompt("Podaj liczbe z zakresu 1-100");
  18.  
  19. while(szukana>100 || szukana<1)
  20. {
  21. szukana=prompt("NIEPRAWIDŁOWA LICZBA! \nPodaj liczbe z zakresu 1-100");
  22.  
  23. }
  24.  
  25.  
  26. var czy_to_ta=confirm("Czy myślisz o "+srednia+"?");
  27.  
  28. while(czy_to_ta==false)
  29. {
  30.  
  31. czy_to_ta=confirm("Czy jest ona większa od"+srednia+"?")
  32.  
  33.  
  34. if(czy_to_ta)
  35. {
  36.  
  37. l = srednia+1;
  38.  
  39. }
  40. else
  41. {
  42. p = srednia;
  43.  
  44. }
  45. srednia = Math.floor ((l+p)/2);
  46.  
  47. czy_to_ta = confirm("czy myslisz o "+srednia+"?");
  48.  
  49.  
  50. }
  51.  
  52.  
  53.  
  54.  
  55. </script>
  56.  
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement