Deskripsi untuk soal nomor 41 - 42
Perhatikan potongan program berikut:
var
a,b,c,i,j,idx : longint;
ar : array [1..10] of char = ('c','d','x','s','t','t','a','b','j','r');
br,cr : array [1..30] of longint;
begin
a := 1;
b := 7;
c := 10;
for i := a to b do begin
idx := ord(ar[i]) - ord('a') + 1;
br[idx] := br[idx] + 1;
end;
for i := b+1 to c do begin
idx := ord(ar[i]) - ord('a') + 1;
cr[idx] := cr[idx] + 1;
end;
for i := 1 to 26 do
for j := 1 to br[i] do
write(chr(i+96));
for i := 1 to 26 do
for j := 1 to cr[i] do
write(chr(i+96));
writeln();
end.
Catatan:
ord(x) : fungsi mengembalikan nilai ASCII karakter x. ASCII ‘a’, ‘b’, ‘c’, …, ‘z’ berturut-turut adalah 97 – 122.
Apakah output dari program diatas?
Berapakah nilai a, b, dan c masing-masing agar output yang dihasilkan adalah "xastt"?