Advertisement
mvujas

Sestougao

May 5th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.90 KB | None | 0 0
  1. ispis(0, _):- !.
  2. ispis(N, Char):- write(Char),
  3.     write(Char),
  4.     write(Char),
  5.     N1 is N - 1,
  6.     ispis(N1, Char).
  7.  
  8. prog(0, 0, _, _, _):- !.
  9. prog(1, N, N, Full, Empty):-
  10.     prog(0, N, N, Full, Empty),
  11.     !.
  12. prog(1, K, N, Full, Empty):-
  13.     isp(K, N, Full, Empty),
  14.     K1 is K + 1,
  15.     prog(1, K1, N, Full, Empty).
  16. prog(0, K, N, Full, Empty):-
  17.     isp(K, N, Full, Empty),
  18.     K1 is K - 1,
  19.     prog(0, K1, N, Full, Empty).
  20.  
  21. isp(1, N, Full, Empty):-
  22.     M is N - 1,
  23.     ispis(M, Empty),
  24.     ispis(N, Full),
  25.     ispis(M, Empty),
  26.     nl,
  27.     !.
  28. isp(N, N, Full, Empty):-
  29.     M is N - 2,
  30.     ispis(1, Full),
  31.     ispis(M, Empty),
  32.     ispis(N, Full),
  33.     ispis(M, Empty),
  34.     ispis(1, Full),
  35.     nl,
  36.     !.
  37. isp(K, N, Full, Empty):-
  38.     M is N - K,
  39.     L is N + 2 * (K - 2),
  40.     ispis(M, Empty),
  41.     ispis(1, Full),
  42.     ispis(L, Empty),
  43.     ispis(1, Full),
  44.     ispis(M, Empty),
  45.     nl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement