Rabu, 05 Oktober 2011

MENYORTIR ANGKA

program sort_highscore;
var textfile:text;
list:array[1..10] of integer;
i,j,temp:integer;
begin
assign(textfile,'SCORES.TXT');
reset(textfile);
for i:=1 to 10 do readln(textfile,list[i]);
close(textfile);
for i:=1 to 10 do
writeln(i,'. ',list[i]);
{ sort the list }
for i:=1 to 9 do
for j:=i to 10 do
if list[j] begin
temp:=list[i];
list[i]:=list[j];
list[j]:=temp;
end;
for i:=1 to 10 do
writeln(i,'. ',list[i]);
assign(textfile,'SORTED.TXT');
rewrite(textfile);
for i:=1 to 10 do writeln(textfile,list[i]);
close(textfile);
end.

Tidak ada komentar:

Posting Komentar