Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //STACK: T, x
- ALGO (T) {
- st,sx=NIL;
- ct=T;
- lt=NIL;
- WHILE (ct!=NIL || lt!=NIL) DO
- IF (ct!=NIL) THEN
- ret=1;
- x=ct->key%2;
- st=PUSH(st,t);
- sx=PUSH(sx,x);
- ct=ct->dx;
- ELSE
- st=TOP(st);
- sx=TOP(sx);
- IF (lt!=ct->sx && ct->sx !=NIL) THEN
- a=elem;
- x=a+x;
- ct=ct->sx;
- ELSE
- IF (ct->sx=NIL) THEN
- a=elem;
- x=a+x;
- y=NIL;
- ELSE
- y=elem;
- ret=x*y*ct->key;
- st=POP(st);
- sx=POP(sx);
- elem=ret;
- lt=ct;
- ct=NIL;
- return elem;
- }
- //DUBBI se pushare di nuovo x quando faccio x=a+x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement