Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. //STACK: T, x
  2.  
  3. ALGO (T) {
  4. st,sx=NIL;
  5. ct=T;
  6. lt=NIL;
  7. WHILE (ct!=NIL || lt!=NIL) DO
  8. IF (ct!=NIL) THEN
  9. ret=1;
  10. x=ct->key%2;
  11. st=PUSH(st,t);
  12. sx=PUSH(sx,x);
  13. ct=ct->dx;
  14. ELSE
  15. st=TOP(st);
  16. sx=TOP(sx);
  17. IF (lt!=ct->sx && ct->sx !=NIL) THEN
  18. a=elem;
  19. x=a+x;
  20. ct=ct->sx;
  21. ELSE
  22. IF (ct->sx=NIL) THEN
  23. a=elem;
  24. x=a+x;
  25. y=NIL;
  26. ELSE
  27. y=elem;
  28. ret=x*y*ct->key;
  29. st=POP(st);
  30. sx=POP(sx);
  31. elem=ret;
  32. lt=ct;
  33. ct=NIL;
  34. return elem;
  35. }
  36.  
  37. //DUBBI se pushare di nuovo x quando faccio x=a+x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement