Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE Jul2003;
- FROM InOut IMPORT WriteLn,WriteString;
- FROM InOut IMPORT WriteLn,WriteString;
- FROM Stek IMPORT StekTip,Push,Top,Pop,MakeNull,Empty;
- FROM Info IMPORT InfoTip;
- PROCEDURE zanimljiv(broj : CARDINAL) : BOOLEAN;
- BEGIN
- IF broj <= 1 THEN
- RETURN FALSE
- ELSIF broj MOD 7 = 2 THEN
- RETURN TRUE
- ELSIF zanimljiv(broj DIV 10) OR zanimljiv(broj DIV 9) THEN
- RETURN zanimljiv(broj DIV 8)
- ELSE
- RETURN FALSE
- END
- END zanimljiv;
- PROCEDURE Szanimljiv(broj: CARDINAL) : BOOLEAN;
- VAR
- rez: BOOLEAN;
- ok,jos: BOOLEAN;
- s: StekTip;
- el: InfoTip;
- BEGIN
- MakeNull(s);
- WHILE (broj > 1) AND (broj MOD 7 <> 2) DO
- el.broj:= broj;
- el.adr:= 1;
- Push(s,el,ok);
- broj:= broj DIV 10;
- END;
- IF broj <= 1 THEN
- rez:= FALSE;
- ELSE
- rez:= TRUE;
- END;
- jos:= TRUE;
- WHILE jos AND NOT Empty(s) DO
- Top(s,el,ok);
- Pop(s,ok);
- broj:= el.broj;
- IF el.adr = 1 THEN
- el.PrviRez:= rez;
- el.adr:= 2;
- Push(s,el,ok);
- broj:= broj MOD 9;
- jos:= FALSE;
- ELSIF el.adr = 2 THEN
- el.DrugiRez:= rez;
- IF el.PrviRez OR el.DrugiRez THEN
- el.adr:= 3;
- Push(s,el,ok);
- broj:= broj DIV 8;
- jos:= FALSE;
- ELSE
- rez:= FALSE;
- END;
- END;
- END;
- UNTIL Empty(s);
- RETURN rez;
- END Szanimljiv;
- BEGIN
- IF zanimljiv(93) THEN
- WriteLn;
- WriteString("Zanimljiv");
- ELSE
- WriteLn;
- WriteString("nije");
- END;
- IF Szanimljiv(93) THEN
- WriteLn;
- WriteString("Zanimljiv");
- ELSE
- WriteLn;
- WriteString("nije");
- END;
- END Jul2003.
- DEFINITION MODULE Info;
- TYPE
- InfoTip = RECORD
- broj: CARDINAL;
- adr: CARDINAL;
- PrviRez,DrugiRez: BOOLEAN;
- END;
- END Info.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement