Bubble Sort of a file of records in Pascal pls

Reply

Join Date: Dec 2006
Posts: 7
Reputation: Berniceazzopard is an unknown quantity at this point 
Solved Threads: 0
Berniceazzopard Berniceazzopard is offline Offline
Newbie Poster

Bubble Sort of a file of records in Pascal pls

 
0
  #1
Jan 18th, 2007
hey i am trying to sort a file of records by name. Im trying to use the bubble sort but all the code i ve found is with the use of arrays. Any idea pls.

Procedure Bubble_Sort;

var
a : array [1..20] of string;
i,j : integer;
t : string;

begin
clrscr;
create_client;
for i:= 1 to Filesize(C) do
Read(C,recc);
a[i]:= recc.name;

for i := 1 to Filesize(C) do
for j := 1 to Filesize(C)-1 do

if a [j] > a[j+1] then
begin
t := a[j];
a[j] := a[j+1];
a[j+1] := t;
end;

writeln;
for i := 1 to filesize(C) do writeln(a[i]);

readln;
end;
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 171
Reputation: radu84 is an unknown quantity at this point 
Solved Threads: 16
radu84 radu84 is offline Offline
Junior Poster

Re: Bubble Sort of a file of records in Pascal pls

 
0
  #2
Jan 20th, 2007
you are using i variable both in reading the file and in the first for cycle.

best regards,
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC