From: Doni Pracner Date: Wed, 6 Nov 2013 12:18:21 +0000 (+0100) Subject: Cas06 - 05. NizDin X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=2e4eba48eaf25a5207b9e61c667783fea9343da6;p=spa2-teorijske-vezbe.git Cas06 - 05. NizDin --- diff --git a/05. NizDin/NIZDIN.MOD b/05. NizDin/NIZDIN.MOD new file mode 100644 index 0000000..6156e77 --- /dev/null +++ b/05. NizDin/NIZDIN.MOD @@ -0,0 +1,65 @@ +MODULE NizDin; + + FROM IO IMPORT + WrStr, RdInt, WrInt; + + CONST + MaxN = 1000; + + VAR + a, b: ARRAY [0 .. MaxN] OF INTEGER; + (* b[i] je suma elemenata u resenju za *) + (* deo niza 'a' do 'i'-tog elementa *) + n: INTEGER; + + PROCEDURE Unos; + VAR + i: CARDINAL; + BEGIN + WrStr('Unesite N: '); + n:= RdInt(); + FOR i:= 1 TO n DO + WrStr('A['); + WrInt(i, 1); + WrStr('] = '); + a[i]:= RdInt(); + END; + END Unos; + + PROCEDURE Resi; + VAR + i, j, Pom: CARDINAL; + BEGIN + b[0]:= 0; + IF a[1] > 0 THEN + b[1]:= a[1]; + ELSE + b[1]:= 0; + END; + FOR i:= 2 TO n DO + IF b[i - 2] + a[i] > b[i - 1] THEN + b[i]:= b[i - 2] + a[i]; + ELSE + b[i]:= b[i - 1]; + END + END; + END Resi; + + PROCEDURE Ispis(n: CARDINAL); + BEGIN + IF n > 0 THEN + IF b[n] = b[n - 1] THEN + Ispis(n - 1); + ELSE + Ispis(n - 2); + WrInt(a[n], 8); + END; + END; + END Ispis; + +BEGIN + Unos; + Resi; + WrStr('Podniz: '); + Ispis(n); +END NizDin. diff --git a/05. NizDin/Prezentacija.ppt b/05. NizDin/Prezentacija.ppt new file mode 100644 index 0000000..c0ab24e Binary files /dev/null and b/05. NizDin/Prezentacija.ppt differ diff --git a/Cas06/NIZDIN.MOD b/Cas06/NIZDIN.MOD deleted file mode 100644 index 6156e77..0000000 --- a/Cas06/NIZDIN.MOD +++ /dev/null @@ -1,65 +0,0 @@ -MODULE NizDin; - - FROM IO IMPORT - WrStr, RdInt, WrInt; - - CONST - MaxN = 1000; - - VAR - a, b: ARRAY [0 .. MaxN] OF INTEGER; - (* b[i] je suma elemenata u resenju za *) - (* deo niza 'a' do 'i'-tog elementa *) - n: INTEGER; - - PROCEDURE Unos; - VAR - i: CARDINAL; - BEGIN - WrStr('Unesite N: '); - n:= RdInt(); - FOR i:= 1 TO n DO - WrStr('A['); - WrInt(i, 1); - WrStr('] = '); - a[i]:= RdInt(); - END; - END Unos; - - PROCEDURE Resi; - VAR - i, j, Pom: CARDINAL; - BEGIN - b[0]:= 0; - IF a[1] > 0 THEN - b[1]:= a[1]; - ELSE - b[1]:= 0; - END; - FOR i:= 2 TO n DO - IF b[i - 2] + a[i] > b[i - 1] THEN - b[i]:= b[i - 2] + a[i]; - ELSE - b[i]:= b[i - 1]; - END - END; - END Resi; - - PROCEDURE Ispis(n: CARDINAL); - BEGIN - IF n > 0 THEN - IF b[n] = b[n - 1] THEN - Ispis(n - 1); - ELSE - Ispis(n - 2); - WrInt(a[n], 8); - END; - END; - END Ispis; - -BEGIN - Unos; - Resi; - WrStr('Podniz: '); - Ispis(n); -END NizDin. diff --git a/Cas06/Prezentacija.ppt b/Cas06/Prezentacija.ppt deleted file mode 100644 index c0ab24e..0000000 Binary files a/Cas06/Prezentacija.ppt and /dev/null differ