# Untitled

unknown
pascal
a month ago
2.1 kB
3
Indexable
Never
```program DataManagement;
uses crt;

var
arr: array[1..100] of integer;
n, i, j, temp, cari, pos: integer;
found: boolean;

procedure BubbleSortAscending(var arr: array of integer; n: integer);
var
i, j, temp: integer;
begin
for i := 0 to n-1 do
begin
for j := 0 to n-i-2 do
begin
if arr[j] > arr[j+1] then
begin
temp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := temp;
end;
end;
end;
end;

procedure BubbleSortDescending(var arr: array of integer; n: integer);
var
i, j, temp: integer;
begin
for i := 0 to n-1 do
begin
for j := 0 to n-i-2 do
begin
if arr[j] < arr[j+1] then
begin
temp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := temp;
end;
end;
end;
end;

procedure SequentialSearch(var arr: array of integer; n, cari: integer; var pos: integer; var found: boolean);
var
i: integer;
begin
found := false;
for i := 0 to n-1 do
begin
if arr[i] = cari then
begin
found := true;
pos := i+1;
break;
end;
end;
end;

begin
clrscr;

write('Input jumlah data: ');

for i := 1 to n do
begin
write('Data ke-', i, ': ');
end;

writeln('Data yang diinput:');
for i := 1 to n do
write(arr[i], ' ');
writeln;

BubbleSortAscending(arr, n);

writeln('Urutan data ascending:');
for i := 1 to n do
write(arr[i], ' ');
writeln;

BubbleSortDescending(arr, n);

writeln('Urutan data descending:');
for i := 1 to n do
write(arr[i], ' ');
writeln;

write('Input data yang anda cari: ');