level 1
var bj,ans,tmp,i:longint;
st:string;
begin
readln(st);
for i:=1 to length(st) do
if st[i]in['-','+'] then begin
case bj of
0:ans:=ans+tmp;
1:ans:=ans-tmp;
end;
case st[i] of
'+':bj:=0;
'-':bj:=1;
end;
tmp:=0;
end
else tmp:=tmp*10+ord(st[i])-48;
case bj of
0:ans:=ans+tmp;
1:ans:=ans-tmp;
end;
writeln(ans);
end.
tmp:=tmp*10+ord(st[i])-48; 这行是什么意思?
2016年06月25日 07点06分
1
st:string;
begin
readln(st);
for i:=1 to length(st) do
if st[i]in['-','+'] then begin
case bj of
0:ans:=ans+tmp;
1:ans:=ans-tmp;
end;
case st[i] of
'+':bj:=0;
'-':bj:=1;
end;
tmp:=0;
end
else tmp:=tmp*10+ord(st[i])-48;
case bj of
0:ans:=ans+tmp;
1:ans:=ans-tmp;
end;
writeln(ans);
end.
tmp:=tmp*10+ord(st[i])-48; 这行是什么意思?