Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Type
- Op = record
- t : Char;
- a, b : Integer;
- end;
- Var
- ops : array [1..10000] of Op;
- mem : array [1..100] of integer;
- i, n : integer;
- a, b : integer;
- c1, c2 : char;
- Begin
- ReadLn(n);
- for i := 1 to n do
- ReadLn(ops[i].t, c1, c2, ops[i].a, ops[i].b);
- i := 1;
- while i <= n do
- begin
- a := ops[i].a;
- b := ops[i].b;
- case ops[i].t of
- 's' : mem[a] := b;
- 'a' : Inc(mem[a], mem[b]);
- 'm' : mem[a] := mem[b];
- 'l' : begin
- Dec(mem[a]);
- if mem[a] > 0 then
- Dec(i, b + 1);
- end;
- 'o' : if b = 1 then
- WriteLn(mem[a])
- else
- WriteLn(Chr(mem[a]));
- end; { case }
- Inc(i);
- end; { while }
- End.
Add Comment
Please, Sign In to add comment