program mengurutkan_bilangan;
uses crt;
var
y:array[1..100] of integer;
a,b,n,i,c,temp:integer;
begin
clrscr;
writeln('************* Selamat Datang ************');
writeln('** Program Mengurutkan n buah bilangan **');
writeln('************ Selamat bekerja ************');
writeln;
write('Masukkan banyak bilangan : ');
readln(n);
writeln;
for i:=1 to n do
begin
write('Masukkan bilangan ke-',i,' : ');
readln(y[i]);
end;
for a:=1 to n-1 do
begin
for b:=a+1 to n do
begin
if y[a] > y[b] then
begin
temp := y[a];
y[a] := y[b];
y[b] := temp;
end;
end;
end;
writeln;
writeln('Berikut bilangan yang telah urut :');
for i:=1 to n do
writeln('Bilangan ke-',i,' : ',y[i]);
readln;
end.
uses crt;
var
y:array[1..100] of integer;
a,b,n,i,c,temp:integer;
begin
clrscr;
writeln('************* Selamat Datang ************');
writeln('** Program Mengurutkan n buah bilangan **');
writeln('************ Selamat bekerja ************');
writeln;
write('Masukkan banyak bilangan : ');
readln(n);
writeln;
for i:=1 to n do
begin
write('Masukkan bilangan ke-',i,' : ');
readln(y[i]);
end;
for a:=1 to n-1 do
begin
for b:=a+1 to n do
begin
if y[a] > y[b] then
begin
temp := y[a];
y[a] := y[b];
y[b] := temp;
end;
end;
end;
writeln;
writeln('Berikut bilangan yang telah urut :');
for i:=1 to n do
writeln('Bilangan ke-',i,' : ',y[i]);
readln;
end.
0 comments:
Posting Komentar