Advertisement
Davencode

Untitled

Jan 7th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. ALGOIT(T)
  2. ST=STX=LAST=NIL
  3. ct=t
  4. while(ct!=NIL || st!=NIL)do
  5. if(ct!=NIL)then
  6. ret=1
  7. x=ct->key%2
  8. st=push(st,ct)
  9. stx=push(stx,x)
  10. ct=ct->dx
  11. else
  12. ct=top(st); x=top(stx)
  13. if(last!=ct->sx && ct->sx!=NIL)then
  14. a=val
  15. x=a+x
  16. pop(stx)
  17. stx=push(stx,x)
  18. ct=ct->sx
  19. else
  20. if(ct->sx=NIL)then
  21. x=a+x
  22. y=1
  23. ret=x*y*ct->key
  24. last=ct
  25. ct=NIL
  26. pop(st,x)
  27. else
  28. y=val
  29. ret=top(stx)*y*ct->key
  30. last=ct
  31. ct=NIL
  32. pop(st,x) //abbreviato sto poppando sia st che x
  33. return ret
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement