Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- empty_stack([]).
- push(Q, X, [X|Q]).
- top([H|T], H).
- pop([H|T], T).
- progr:-
- empty_stack(L),
- read_stack(L,0).
- read_stack(L,5):-
- print_stack(L, 0).
- print_stack(L,5):-
- write("telos").
- read_stack(L,Cnt):-
- write("dose stoixeio "),
- read(El),
- push(L, El, NewL),
- NCnt is Cnt+1,
- read_stack(NewL,NCnt).
- print_stack(L, Cnt):-
- top(L, TopEl),
- nl,
- write(TopEl),
- pop(L,NewL),
- NCnt is Cnt+1,
- print_stack(NewL, NCnt).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement