Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <form method="post">
- A= <input name="a" /></br>
- B= <input name="b" /></br>
- C= <input name="c" /></br>
- <input type="submit" value="Rozwiąż równanie" />
- </form>
- <?php
- $a = @$_POST['a'];
- $b = @$_POST['b'];
- $c = @$_POST['c'];
- if($a==null || $b==null || $c==null || $a==0) {echo "Wprowadź poprawne dane";}
- else{
- $a = @$_POST['a'];
- $b = @$_POST['b'];
- $c = @$_POST['c'];
- echo "a = $a<br>b = $b<br>c = $c";
- $delta=pow($b,2)-(4*$a*$c);
- echo "<br>Delta równania wynosi $delta";
- if($delta<0){
- echo "<br>Funkcja nie posiada pierwiastków.";
- }
- else if($delta>0){
- $x1=(-$b+sqrt($delta))/(2*$a);
- $x2=(-$b-sqrt($delta))/(2*$a);
- echo "<br>x<sub>1</sub> = $x1 <br> x<sub>2</sub> = $x2";
- }
- else {
- $x=-$b/(2*$a);
- echo "<br>x<sub>1</sub> = $x";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement