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

Olimpiade Sains Provinsi (OSP) 2017 - Komputer , Nomor 45

45

Tuliskan output program berikut.

program Soal1;

function ini(x: integer): integer; forward;
function soal(x: integer): integer; forward;
function gampang(x: integer): integer; forward;
function banget(x: integer): integer; forward;

function ini(x: integer): integer;
begin
  if (x = 1) then
    ini := 1
  else
  if (x <= 0) then
    ini := 0
  else
    ini := -soal(x) + gampang(x);
end;

function soal(x: integer): integer;
begin
  if (x <= 2) then
    soal := -ini(x-1)
  else
  soal := -gampang(x) + banget(x) div 2;
end;

function gampang(x: integer): integer;
begin
  if (x <= 3) then
    gampang := ini(x-2)
  else
    gampang := -banget(x) div 2 + ini(x-4);
end;

function banget(x: integer): integer;
begin
  if (x <= 4) then
    banget := -2*ini(x-3)
  else
  banget := -2*(gampang(x-2) - soal(x-4));
end;

var
  kenapa: integer;
begin
  kenapa := ini(2) - soal(6) - gampang(5) + banget(4);
  writeln(kenapa);
end.