09. Longer Line от 09. Longer Line тип данни
Едининя тест ми фейлна. Това от типа на данните ли е, или закръгляне?
<?php
//You are given the coordinates of four points in the 2D plane. The first and the second pair of points form two
//different lines. Print the longer line in format "(X1, Y1)(X2, Y2)" starting with the point that is closer to the center of
//the coordinate system (0, 0) (You can reuse the method that you wrote for the previous problem). If the lines are of
//equal length, print only the first one.
function Line($x1, $y1, $x2, $y2)
{
$length = sqrt(pow($x1-$x2, 2) + pow($y1-$y2, 2));
return $length;
}
function nearestPoint($x1, $y1, $x2, $y2)
{
$first = sqrt(pow($x1, 2) + pow($y1, 2));
$second= sqrt(pow($x2, 2) + pow($y2, 2));
if ($first <= $second)
{
printf("(%d, %d)(%d, %d)", $x1, $y1, $x2, $y2);
}
else
{
printf("(%d, %d)(%d, %d)", $x2, $y2, $x1, $y1);
}
}
$x1=floatval(readline());
$y1=floatval(readline());
$x2=floatval(readline());
$y2=floatval(readline());
$k1=floatval(readline());
$j1=floatval(readline());
$k2=floatval(readline());
$j2=floatval(readline());
if(Line($x1, $y1, $x2, $y2)>Line($k1, $j1, $k2, $j2))
{
// echo Line($x1, $y1, $x2, $y2)."\n";
// echo Line($k1, $j1, $k2, $j2)."\n";
// echo "(".$x1.", ". $y1.")";
// echo "(".$x2.", ". $y2.")";
nearestPoint($x1, $y1, $x2, $y2);
}
else
{
// echo Line($x1, $y1, $x2, $y2)."\n";
// echo Line($k1, $j1, $k2, $j2)."\n";
//
// echo "(".$k1.", ". $j1.")";
// echo "(".$k2.", ". $j2.")";
nearestPoint($k1, $j1, $k2, $j2);
}
Не виждам къде можфе да е грешката, идеи? Благодаря предварително!
суперм ,мерси