Advertisement
TreuW

Kwadradowe

Sep 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <title>rownanie kwadradowe</title>
  5. <meta charset="utf-8">
  6. </head>
  7. <body><style></style>
  8. <h1>rownanie kwadradowe</H1><hr></hr>
  9. <p>wpisz współczynniki a, b i c rówania <b>ax+b=c</b> , a nastepnie kliknij przycisk <i><b>roziwiąż</b></i> , aby wyswietlic rozwiazanie rownania</p>
  10. <form method="GET">
  11. a:
  12. <input type="number" step="0.001" name="a" required> </br></br>
  13. b:
  14. <input type="number" step="0.001" name="b" required> </br></br>
  15. c:
  16. <input type="number" step="0.001" name="c" required> </br></br>
  17.  
  18. <input type="submit" value="rozwiąż">
  19. </form>
  20. <hr></hr>
  21. <?php
  22. if(isset($_GET['a'])&&isset($_GET['b'])&&isset($_GET['c']))
  23. {
  24. $a=$_GET['a'];
  25. $b=$_GET['b'];
  26. $c=$_GET['c'];
  27. $delta=($b*$b)-(4*$a*$c);
  28.  
  29. if($delta>0)
  30. {
  31. $x1=(-$b-sqrt($delta))/2/$a;
  32. $x2=(-$b+sqrt($delta))/2/$a;
  33. echo 'x1 wynosi '.$x1.'<br>';
  34. echo 'x2 wynosi '.$x2;
  35. }
  36. else
  37. {
  38. if($delta==0)
  39. {
  40. $x3=-($b/2*$a);
  41. echo 'równanie ma tylko jeden wynik czyli ' .$x3;
  42. }
  43. else
  44. {
  45. echo 'nie ma rozwiązania';
  46. }
  47. }
  48. }
  49. ?>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement