Pliki - sortowanie.

0

Program liczy mi tylko azymut ostatniego punktu, który podam, a powinien to robić dla każdego punktu. Program ma zapisac do innego pliku tekstowego punkty z pliku pierwszego, dla ktorych znamy komplet wspolrzednych. Punkty, przed zapisanie do nowego pliku maja byc posortowane. Sortowanie wg azumutu, gdzie punktem poczatkowym jest punkt o wsp., ktore uzytkownik wprowadzi z klawiatury.
Proszę o pomoc i wskazanie co robię źle

program Project1;

{$APPTYPE CONSOLE}

uses
SysUtils;

var f,q:text;
wx,wy,wz,xa,ya,A,dx,dy,x,y:real;
nr:integer;
P:array[1..100] of record
x,y,z:real;
o:String[2];
end;
n,i,j,tmp:0..100;
tablica:array[0..100] of integer;

begin
{ TODO -oUser -cConsole Main : Insert code here }

Assign(f,'c:\dane.txt');
rewrite(f);
write('Podaj liczbe punktow (max 100) '); readln(n);
for i:=1 to n do
begin
write('Podaj numer punktu '); readln(nr);
write('Podaj X '); readln(wx);
write('Podaj Y '); readln(wy);
write('Podaj Z '); readln(wz);
writeln(f,nr,' ',wx2,wy2,wz2);
end;

close(f);

reset(f);
write('Podaj wspolrzedna x punktu do azymutu '); readln(xa);
write('Podaj wspolrzedna y punktu do azymutu '); readln(ya);

if wz<>0 then


for i:= 1 to n do

begin

dx:=wx-xa;
dy:=wy-ya;
   if (dx = 0) and (dy > 0) then A:= 100

else if (dx = 0) and (dy < 0) then A:= 300
else if (dx > 0) and (dy = 0) then A:= 0
else if (dx < 0) and (dy = 0) then A:= 200
else if (dx <> 0) and (dy <> 0) then
begin
A:=arctan ( abs (dy / dx) );
A:= A * 200 / PI;
end;

if A < 0 then A := -A ;
if (dx < 0) and (dy > 0) then A := 200 - A;
if (dx < 0) and (dy < 0) then A := 200 + A;
if (dx > 0) and (dy < 0) then A := 400 - A;
writeln (' Azymut (grady): ', A2);
writeln;

end;

close(f);

for i:=0 to n-1 do
for j:=0 to n-1 do
if (tablica[j]>tablica[j+1]) then
begin
tmp := tablica[j];
tablica[j] := tablica[j+1];
tablica[j+1] := tmp;
end;

Assign(q,'c:\sort.txt');
rewrite(q);
reset(f);
while not Eof(f) do
begin
readln(f,i);
for i:=1 to n do
begin
writeln(q,nr,' ',wx2,wy2);
end;
end;
closefile(f);
closefile(q);

0
var f,q:text;
    wx,wy,wz,xa,ya,A,dx,dy,x,y:real;
    nr:integer;
    P:array[1..100] of record
                        x,y,z:real;
                        o:String[2];
                        end;
    n,i,j,tmp:0..100;
    tablica:array[0..100] of integer;

1 użytkowników online, w tym zalogowanych: 0, gości: 1