Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  
  5. </head>
  6. <body>
  7. <form>
  8. <p>pierwsza liczba:</p><input type = "number" value="0" id="input1">
  9.  
  10. <br />
  11. <p>druga liczba:</p><input type = "number" value="0" id="input2">
  12.  
  13. <br />
  14. <p>trzecia liczba:</p><input type = "number" value="0" id="input3">
  15.  
  16. <br />
  17. <p>czwarta liczba:</p><input type = "number" value="0" id="input4">
  18. <input type ="button" value="submit" id="subyeet" onclick="inputo1()">
  19. <div id="idk"></div>
  20.  
  21. </form>
  22. <script>
  23. let t1 = new Array ();
  24.  
  25. function inputo1()
  26. {
  27. let min, max, srednia;
  28. let grab1 = document.getElementById("input1").value;
  29. let grab2 = document.getElementById("input2").value;
  30. let grab3 = document.getElementById("input3").value;
  31. let grab4 = document.getElementById("input4").value;
  32.  
  33. t1[0] = Number(grab1.value);
  34. t1[1] = Number(grab2.value);
  35. t1[2] = Number(grab3.value);
  36. t1[3] = Number(grab4.value);
  37.  
  38. for (let i =0; i <=t1.length; i++)
  39. {
  40. if(i=0)
  41. {
  42. min = t1[i];
  43. max = t1[i];
  44. }
  45. else{
  46. if(t1[i]>max) max = t1[i];
  47. if(t1[i]>min) min = t1[i];
  48. }
  49.  
  50. }
  51.  
  52. return (wynik);
  53. document.getElementById("idk").innerHTML=wynik;
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. // napisac aplikacje pozwalajaca na obliczenie sumy i sredniej arytmetycznej oraz wyznaczenie wartosci najwiekszej i najmniejszej elementow zapammietanych w 4 elementowej tablicy
  63. </script>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement