Advertisement
ShadowEmbrace

longerLine

Oct 20th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. $x1 = intval(readline());
  5. $y1 = intval(readline());
  6. $x2 = intval(readline());
  7. $y2 = intval(readline());
  8. $x3 = intval(readline());
  9. $y3 = intval(readline());
  10. $x4 = intval(readline());
  11. $y4 = intval(readline());
  12.  
  13. $line1 = calculateLineLength($x1, $y1, $x2, $y2);
  14. $line2 = calculateLineLength($x3, $y3, $x4, $y4);
  15.  
  16. function calculateLineLength(int $x1, int $y1, int $x2, int $y2): float {
  17.     $result = sqrt(((pow($x2 - $x1, 2)) + ((pow($y2 - $y1, 2)))));
  18.     return $result;
  19. }
  20.  
  21. if ($line1 >= $line2) {
  22.     if (abs($x1) < abs($x2) && abs($y1) < abs($y2)) {
  23.         printf("(%d, %d)(%d, %d)", $x1, $y1, $x2, $y2);
  24.     } else {
  25.         printf("(%d, %d)(%d, %d)", $x2, $y2, $x1, $y1);
  26.     }
  27. } else {
  28.     if (abs($x3) < abs($x4) && abs($y3) < abs($y4)) {
  29.         printf("(%d, %d)(%d, %d)", $x3, $y3, $x4, $y4);
  30.     } else {
  31.         printf("(%d, %d)(%d, %d)", $x4, $y4, $x3, $y3);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement