Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>04.Triangle Area</title>
- <meta charset="windows-1251"/>
- </head>
- <body>
- <h2>Координати X и Y</h2>
- <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- точка А <input type="" name="Ax" size="5" value="0">
- <input type="" name="Ay" size="5" value="0"><br/>
- точка В <input type="" name="Bx" size="5" value="0">
- <input type="" name="By" size="5" value="0"><br/>
- точка С <input type="" name="Cx" size="5" value="0">
- <input type="" name="Cy" size="5" value="0"><br/>
- <input type="submit" name="send" value="OK">
- </form>
- <!-- K = |Ax(By - Cy) + Bx(Cy - Ay) + Cx(Ay-By)|/2 -->
- <?php
- if(isset($_GET['send'])){
- $Ax = $_GET['Ax'];
- $Ay = $_GET['Ay'];
- $Bx = $_GET['Bx'];
- $By = $_GET['By'];
- $Cx = $_GET['Cx'];
- $Cy = $_GET['Cy'];
- $area = abs(($Ax*($By-$Cy))+($Bx*($Cy-$Ay))+($Cx*($Ay-$By)))/2; //abs - модул
- if(is_numeric($Ax) && is_numeric($Ay) && is_numeric($Bx) && is_numeric($By) && is_numeric($Cx) && is_numeric($Cy)){
- echo "<h2>Резултат</h2>";
- echo "Координати на точка А ($Ax, $Ay), Координати на точка В ($Bx, $By), Координати на точка С ($Cx, $Cy) <br/>";
- echo "Краен резултат = ".floor($area); //Закръгляне до цяло число
- }
- else{
- echo "Въведените стойности трябва да са положителни или отрицателни числа!";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement