Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- ggg,s,s1,s2:string;
- i,p,itog1,itog2:integer;
- mass:array [1..5] of integer;
- a,b,e:integer;
- begin
- e:=10;
- read(s);
- ggg:=copy(s,1,1);
- val(ggg,b,e);
- mass[1]:=b;
- p:=1;
- for i:=2 to length(s) do
- if i mod 2 <>0 then
- begin
- s1:=copy(s,i,1);
- val(s1,a,e);
- mass[i-p]:=a;
- p:=p*2;
- end
- else
- begin
- s2:=s2+copy(s,i,1);
- end;
- if (s2[1]='+') then itog1:= mass[1]+mass[2]
- else itog1:= mass[1]-mass[2];
- for i:=2 to length(s2) do
- begin
- if (s2[i]='+') then
- itog2:=itog1+mass[i+1]
- else
- itog2:=itog1-mass[i+1];
- end;
- writeln(itog2);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement