-
Notifications
You must be signed in to change notification settings - Fork 0
/
resuelve.php
50 lines (44 loc) · 869 Bytes
/
resuelve.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
function resolver_ecuacion($a, $b, $c)
{
$auxiliar = (pow($b,2) - (4 * $a * $c));
if($auxiliar >= 0)
{
$x1 = (-$b + sqrt($auxiliar)) / (2 * $a);
$x2 = (-$b - sqrt($auxiliar)) / (2 * $a);
if($x1 == $x2)
{
echo "ecuación con solución unica x:".$x1."<br>";
}
else
{
echo "Soluciones de la ecaución <br> x1: ".$x1."<br>x2: ".$x2."<br>";
}
}
else
{
echo "Ecuación con raices imaginarias";
}
}
if($a == '0')
{
//throw new Exception("Error de división por cero");
echo '2';
}
elseif($b == '0' || $c == '0')
{
resolver_ecuacion($a, $b, $c);
}
elseif(empty($a) || empty($b) || empty($c))
{
//echo "Llene todos los campos";
echo "1";
}
else
{
resolver_ecuacion($a, $b, $c);
}
?>