I wrote this program and I just can't figure out what is wrong with it. The SkaitytiDuomenis (read values) procedure takes two arrays as arguments so it can read coordinates from a text file and store them in the arrays, but the problem is it doesn't really read it. There is something wrong with the assign() part, but I can't figure it out for the life of me. Anyone who helps will be greatly appreciated, as this is a state exam I'm trying to prepare for.
program Uzduotis1;
type
masyvas = array[1..50] of integer;
{*************************Kintamieji************************}
var
Duomenys, Rezultatai :text;
x, y :masyvas; {koordinates (x;y) }
UzsakymuSk, {uzsakymu skaicius}
DienosKm, {dienos kilometrazo limitas}
NuvaziuotiKm, {nuvaziuotu kilometru suma}
LikeKlientai, {neaptarnautu klientu skaicius}
UzsakymoNr {atliekamo uzsakymo numeris}
:integer;
{*************************Proceduros************************}
procedure SkaitytiDuomenis(var a,b:masyvas);
var i:integer;
begin
for i:=1 to UzsakymuSk do
readln(Duomenys, a[i], b[i]);
end;
procedure IsvestiRezultatus;
begin
rewrite(Rezultatai);
write(LikeKlientai,' ',NuvaziuotiKm);
close(Rezultatai)
end;
{************************Funkcijos**************************}
function atstumas(a,b :integer) :integer;
begin
atstumas := (abs(a) + abs(b)) * 2;
end;
{********************Pagrindine programa********************}
begin
assign(Duomenys,'C:\Duomenys\U1.txt');
assign(Rezultatai,'C:\Duomenys\U1rez.txt');
reset(Duomenys);
readln(Duomenys,UzsakymuSk,DienosKm);
SkaitytiDuomenis(x,y);
NuvaziuotiKm := 0;
LikeKlientai := UzsakymuSk;
UzsakymoNr := 1;
while ((UzsakymoNr<UzsakymuSk) and (NuvaziuotiKm<DienosKm)) do
begin
NuvaziuotiKm := NuvaziuotiKm + atstumas(x[UzsakymoNr],y[UzsakymoNr]);
LikeKlientai := LikeKlientai - 1;
UzsakymoNr := UzsakymoNr + 1
end;
IsvestiRezultatus;
end.
This is the input file:
14 30
2 3
3 –1
-2 –4
–3 0
-2 4
0 2
5 -4
1 2
4 -3
2 1
-5 -5
-1 0
0 5
2 5