Решение задач
<?php
class Trapeci {
public $x1;
public $x2;
public $x3;
public $x4;
public $y1;
public $y2;
public $y3;
public $y4;
public $a;
public $b;
public $DA;
public $BC;
public $AB;
public $CD;
public $Dlina;
public $perimetr;
public $s;
function __construct ($x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4) {
$this-> x1 = $x1 ;
$this-> y1 = $y1 ;
$this-> x2 = $x2 ;
$this-> y2 = $y2 ;
$this-> x3 = $x3 ;
$this-> y3 = $y3 ;
$this-> x4 = $x4 ;
$this-> y4 = $y4 ;
$this-> a= sqrt(pow( $this-> x4 - $this-> x3,2) + pow($this-> y4 - $this-> y3,2));
// echo "a :", $this-> a;
$this-> b= sqrt(pow( $this-> y2 - $this-> y1,2) + pow($this-> x2 - $this-> x1,2));
// echo " b :", $this-> b,"<BR>";
$this-> DA = sqrt(pow($this-> x4 - $this-> x1,2) + pow($this-> y4 - $this-> y1,2));
$this-> BC = sqrt(pow($this-> x3 - $this-> x1,2) + pow($this-> y3 - $this-> y1,2));
$this-> AB = sqrt(pow($this-> x2 - $this-> x1,2) + pow($this-> y2 - $this-> y1,2));
$this-> CD = sqrt(pow($this-> x4 - $this-> x3,2) + pow($this-> y4 - $this-> y3,2));
$this-> perimetr = $this-> DA + $this-> BC + $this-> AB + $this-> CD;
$this-> s = (($this-> DA+$this-> BC)/2)* sqrt( pow($this-> AB,2)- pow(($this-> DA-$this-> BC)/2,2) ) ;
}
function TestRavnobochnost () {
if ( $this-> a == $this-> b ) {
echo "<BR> Ravnobochnaya <BR> ";
}
else {
echo " <BR> NeRavnobochnaya <BR> ";
}
}
function Dlina () {
echo " DA: ", $this-> DA,"<BR>" ;
echo "BC: ",$this-> BC,"<BR>";
echo "AB: ",$this-> AB,"<BR>" ;
echo " CD: ", $this-> CD,"<BR>";
}
function Perimetr () {
echo " Perimetr: ", $this-> perimetr,"<BR>";
}
function Ploshad () {
echo " Ploshad: ", $this-> s, "<BR>";
}
function __destruct () {
$this-> x1;
$this-> y1 ;
$this-> x2 ;
$this-> y2;
$this-> x3 ;
$this-> y3;
$this-> x4 ;
$this-> y4;
$this-> s;
$this-> perimetr;
$this-> Dlina;
}
}
$N=3;
for ( $i = 0; $i < $N; $i++) {
$objs[$i] = new Trapeci (rand(5,20),rand(5,20),rand(5,20),rand(5,20),rand(5,20),rand(5,20),rand(5,20),rand(5,20));
$objs[$i]-> TestRavnobochnost ();
$objs[$i]-> Dlina ();
$objs[$i]-> Perimetr ();
$objs[$i]-> Ploshad ();
$summaploshad += $objs[$i]-> s;
}
$srefnyaploshad = $summaploshad/$N;
$k=0;
for ( $i = 0; $i < $N; $i++) {
if ($objs[$i]-> s > $srefnyaploshad) {
$k =$k +1;
}
}
echo "<BR> <BR> <BR> Summa ploshad: ", $summaploshad, "<BR>";
echo $summaploshad, "/",$N, " Srednya ploshad: ", $srefnyaploshad, "<BR>" ;
echo "Kolichtstvo trapecii ploshad bolshe srednei: ", $k;
?>
math2
Fri, 06/19/2020 - 16:44
Permalink
Приветствую!
Приветствую!
Перепишите это частично, применяя английскую терминологию и используя класс Point для точки:
И далее перепишите Trapeci, используя черыре точки:
fgh
Sun, 06/21/2020 - 22:50
Permalink
<?php