Bantu temanmu belajar dengan menambahkan soal di Kujawab. Klik disini..

Olimpiade Sains Provinsi (OSP) 2016 - Komputer , Nomor 31

31

Tuliskanlah keluaran program sebagai berikut:

var
 ar : array[1..10] of integer = (4, 5, 10, 5, 51, 33, 49, 64, 2, 7);
 a, b, c, i : integer;
begin
 a := -1;
 for i := 1 to 10 do begin
 if a = -1 then a := i
 else if ar[i] > ar[a] then a := i;
 end;
 b := -1;
 for i := 1 to 10 do begin
 if i <> a then begin
 if b = -1 then b := i
 else if ar[i] > ar[b] then b := i;
 end;
 end;
 c := -1;
 for i := 1 to 10 do begin
 if (i <> a) and (i <> b) then begin
 if c = -1 then c := i
 else if ar[i] > ar[c] then c := i;
 end;
 end;
 writeln(a, ' ', b, ' ', c);
end.