[ create a new paste ] login | about

Link: http://codepad.org/ve9fAq4J    [ raw code | fork ]

C, pasted on Nov 7:
type points = class
public
     x: real;
     y: real;
public
     constructor Create;
     begin
          x:= 0.0;
          y:= 0.0;
     end;
end;


var i, h, count, min, max, left, right, m1: integer;
    point: array[1..4] of points;


function length(a, b: points): real;
begin
     length:= sqrt( (a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y) );
end;



begin
     for i:= 1 to 4 do
     begin
          point[i]:= points.Create;
          write('Введите Х: ');
          readln(point[i].x);
          
          write('Введите Y: ');
          readln(point[i].y);
     end;
     
     for i:= 1 to 3 do
          for h := i+1 to 4 do
              if (point[i].y = point[h].y) then
                 count:= count + 1;
                 
     m1:= 1;
     max:= 1;
     min:= 1;
     left:= 1;
     right:= 1;
     
     if count < 2 then
     begin
          for i:= 1 to 4 do
          begin
               if (point[max].y < point[i].y) then
                   max:= i
               ;
               if (point[min].y > point[i].y) then
                   min:= i
               ;
          end;
          
          for i:= 1 to 4 do
          begin
               if (point[left].x > point[i].x) then
                   left:= i
               ;
               if (point[right].x < point[i].x) then
                   right:= i
               ;
          end;
     end
     else if count = 2 then
     begin
          for i:= 1 to 4 do
               if (point[max].y < point[i].y) then
                   max:= i
          ;
          
          for i:= 1 to 4 do
               if (point[max].y = point[i].y) and (i <> max) then
                   m1:= i;
                   
          if (point[max].x < point[m1].x) then
          begin
               left:= max;
               max:= m1;
          end
          else left:= m1
          ;
          
          // для min
          for i:= 1 to 4 do
               if (point[min].y > point[i].y) then
                   min:= i
          ;

          m1:= 1;
          for i:= 1 to 4 do
               if (point[min].y = point[i].y) and (i <> min) then
                   m1:= i;

          if (point[min].x > point[m1].x) then
          begin
               right:= min;
               min:= m1;
          end
          else right:= m1
          ;
     end
     else h:= 0;

     if ( (length(point[max], point[right]) - length(point[min], point[left])) + (length(point[max], point[left]) - length(point[min], point[right])) <> 0 ) or (h = 0) then
        writeln('Не подходит')
     else
        writeln('Подходит')
     ;

end.


Create a new paste based on this one


Comments: