witam ;-) kolega poprosil mnie zebym mu napisał jakis tam program, no to cos naskrobałem:
program bro;
type
point = record
x,y: real; {declaration of point type, consisting of two coorginates}
end;
triangle = record {declaration of triangle type, consisting of threepoints}
a,b,c : point;
end;
side = record {declaration of triangle sides lenght type}
A, B, C: real;
end;
var
p1,p2,p3 : point;
t : triangle;
x1,x2,x3,y1,y2,y3 : real;
procedure subprogram1(var x,y:real; p: point); {procedure initialize point (name of points is one of parameters) using 2 coordinates passed as parameters}
begin
p.x:=x;
p.y:=y;
end;
procedure subprogram2(var a,b,c: point); {procedure initialize triangle, using 3 points passed as parameters}
begin
t.a:=p1;
t.b:=p2;
t.c:=p3;
end;
function subprogram3(var t: triangle):boolean; {function returns true if 3 points in triangle type really defines a traingle}
var D,E,F: real;
begin
D := sqrt(sqr(t.a.x - t.b.x) + sqr(t.a.y - t.b.y));
E := sqrt(sqr(t.b.x - t.c.x) + sqr(t.b.y - t.c.y));
F := sqrt(sqr(t.c.x - t.a.x) + sqr(t.c.y - t.a.y));
subprogram3 := (D+E > F) AND (E+F > D) AND (D+F > E);
end;
function subprogram4(var t: triangle):side; {function returns the length of sides of a triangle (passed as parameter) in a defined type}
begin
subprogram4.A := sqrt(sqr(t.a.x - t.b.x) + sqr(t.a.y - t.b.y));
subprogram4.B := sqrt(sqr(t.b.x - t.c.x) + sqr(t.b.y - t.c.y));
subprogram4.C := sqrt(sqr(t.c.x - t.a.x) + sqr(t.c.y - t.a.y));
end;
begin
writeln('Point1 x:'); read(x1);
writeln('Point1 y:'); read(y1);
writeln('Point2 x:'); read(x2);
writeln('Point2 y:'); read(y2);
writeln('Point3 x:'); read(x3);
writeln('Point3 y:'); read(y3);
subprogram1(x1,y1,p1);
subprogram1(x2,y2,p2);
subprogram1(x3,y3,p3);
subprogram2(p1,p2,p3);
if subprogram3(t) then writeln('This is correct triangle') else writeln('Sorry, this is not a triangle');
writeln;
writeln('Lenght of sides in this triangle are:');
writeln(subprogram4(t).A);
writeln(subprogram4(t).B);
writeln(subprogram4(t).C);
end.
mi sie to kompiluje bez problemu, natomiast jemu wyrzuca:
"In function 'Subprogram4'
request for field 'A' in something not a record, schema or object" :/ dla B i C to samo...
ocb ? help :P
