Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program intersection;
- const
- eps = 0.000001;
- maxLines = 500;
- inputFilepath = 'input.txt';
- outputFilepath = 'output.txt';
- type
- Line = record
- a: Real;
- b: Real;
- end;
- var
- df: text;
- i, j: integer;
- a, b, c, d, xp, yp: real;
- lines: array[1..maxLines] of Line;
- begin
- {Reading lines}
- assign(df, inputFilepath);
- reset(df);
- i := 1;
- while not eof(df) do begin
- readln(df, a, b);
- lines[i].a := a;
- lines[i].b := b;
- inc(i);
- end;
- close(df);
- {Writing intersections}
- assign(df, outputFilepath);
- rewrite(df);
- for j:=2 to i-1 do begin
- a := lines[j-1].a;
- c := lines[j-1].b;
- b := lines[j].a;
- d := lines[j].b;
- if abs(a-b)<eps then
- writeln(df, 'parallels')
- else begin
- xp := (d-c)/(a-b);
- yp := a*xp+c;
- writeln(df, xp:0:3, ',', yp:0:3);
- end;
- end;
- close(df);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement