";
$array = preg_split("/x/", $equation);
$array[1] = substr($array[1], 2);
if(empty($array[0]))
{
echo "a is empty
";
$intA = 1;
}
else
{
$intA = $array[0][0];
}
$intA = (int) $intA;
echo "a : " . $intA . "
";
if (strlen($array[1])>3)
{
//got to add b = 10 case
$intB = substr($array[1], -1);
}
else
{
$intB = 1;
}
$intB = (int) $intB;
if (!strcmp($array[1][1], '-'))
{
$intB = -$intB;
}
echo "b : " . $intB . "
";
if(empty($array[2]))
{
$intC = 0;
}
else
{
$intC = substr($array[2], -1);
if (!strcmp($array[2][1], '-'))
{
$intC = -$intC;
}
}
echo "c : " . $intC . "
";
$delta = $intB * $intB * - 4 * $intA * $intC;
echo "delta : " . $delta . "
";
$x1 = (-$intB - sqrt($delta))/(2*$intA);
$x1 = round($x1, 2);
echo "x1 : " . $x1 . "
";
$x2 = (-$intB + sqrt($delta))/(2*$intA);
$x2 = round($x2, 2);
echo "x2 : " . $x2 . "
";
if ($x1 < $x2)
{
echo "Highest is : " . $x2 . "
";
$solution = $x2;
}
else
{
echo "Highest is : " . $x1 . "
";
$solution = $x1;
}
$subm = "https://www.newbiecontest.org/epreuves/prog/verifpr6.php?solution=" . $solution;
header("Location: $subm");
?>