944,147 Members | Top Members by Rank

Ad:
Jan 18th, 2007
0

Bubble Sort of a file of records in Pascal pls

Expand Post »
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;
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Berniceazzopard is offline Offline
7 posts
since Dec 2006
Jan 20th, 2007
0

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

you are using i variable both in reading the file and in the first for cycle.

best regards,
Reputation Points: 14
Solved Threads: 16
Junior Poster
radu84 is offline Offline
171 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: pascal save problem
Next Thread in Pascal and Delphi Forum Timeline: Dephi 7 and magnetic strip





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC