Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <title>Equation du second degre Solver</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <center>
- <img src='http://img.memecdn.com/math_o_166669.jpg' width='350' height='269'/>
- <br />
- <?php
- //M4_HAX0R
- @set_time_limit(0); // منع وقوف السكربت عن العمل
- error_reporting(0); // منع ظهرو الأخطاء
- echo'<form method="GET"><big>
- <font color="red">a</font>x<sup><small>2</small></sup>: <input type="text" size="1" name="a" placeholder="3"/>
- <font color="red">b</font>x: <input type="text" size="1" name="b" placeholder="1"/>
- <font color="red">c</font>: <input type="text" size="1" name="c" placeholder="6"/>
- <input type="submit" value="SOLVE >>"/>
- </big></form>';
- if(!empty($_GET['a']) && !empty($_GET['b']) && !empty($_GET['c'])){ // التأكد من ادخال المعاملات
- // استخراج المعاملات من الفورم
- $a = trim($_GET['a']);
- $b = trim($_GET['b']);
- $c = trim($_GET['c']);
- // جل المعادلة
- $delta = delta($a, $b, $c); // حساب العدد ضيلطا
- if($delta == 0){ // ادا كان العدد ضيلطا يساوي الصفر
- echo"<br />[ <b>Delta = $delta = 0</b> ]<br />"; // ذبع قيمة ضيلطا
- $x = -$b/2*$a; // الحل سيكون على الشكل التالي
- // طباعة الحل
- echo"<b><i>x</i> = <sup>-$b</sup>⁄<sub>2*$a</sub><font size='4' face='Arabic Transparent'> :ادا للمعادلة حل وحيد هو</font></b><br />";
- echo'<br /><font color="blue" size="6">S={</font><big><b>'.$x.'</b></big><font color="blue" size="6">}</font>';
- }elseif($delta>0){ // ادا كان ضيلطا اكبر من الصفر
- echo"<br />[ <b>Delta = $delta > 0</b> ]<br />"; // ذبع قيمة ضيلطا
- // حلول المعادلة
- $x1 = (-$b-sqrt($delta))/(2*$a);
- $x2 = (-$b+sqrt($delta))/(2*$a);
- // طباعة الحل
- echo"<b><i>x</i> = <sup>-$b <i><u>+</u></i>√$delta</sup>⁄<sub>2*$a</sub><font size='4' face='Arabic Transparent'> :للمعادلة حلين حقيقيين مختلفين هما</font></b><br />";
- echo'<br /><font color="blue" size="6">S={</font><big><b>'.$x1.', '.$x2.'</b></big><font color="blue" size="6">}</font>';
- }else{ // ادا كانت ضيلطا اصغر من الصفر فهي الاختيار الوحيد المتبقي ههه
- echo'<br /><font size="5" face="Arabic Transparent"> <big><i>R</i></big> ليس للمعادلة حل في</font></b>'; // طبع ان ليس للمعادلة حل في المجموعة اغ
- }
- }
- function delta($a, $b, $c){ // دالة لحساب قيمة ضيلطا
- return pow($b, 2)-4*$a*$c;
- }
- /*
- pow function: http://www.w3schools.com/php/func_math_pow.asp
- sqrt function: http://www.w3schools.com/php/func_math_sqrt.asp
- */
- ?>
Add Comment
Please, Sign In to add comment