I've solve the problem, but then when i submit it, i got RE!!!
please, if anyone can, take a look at my code, and tell me, why i got RE.
[pascal]
program uva(input,output);
{$IFNDEF ONLINE_JUDGE}
uses crt;
{$ENDIF}
const
infile = '';
outfile = '';
{$IFDEF ONLINE_JUDGE}
type tInt = integer;
{$ELSE}
type tInt = longint;
{$ENDIF}
function getch(var f : text) : char;
var ch : char;
begin
read(f,ch);
while (ch=' ') do read(f,ch);
getch:=ch;
end;
function getstr(var f : text) : string;
var
ch : char;
s : string;
begin
s:='';
ch:=getch(f); s:=s+ch;
while not eoln(f) do
begin
read(f,ch);
if (ch<>' ') then s:=s+ch;
end;
readln(f);
getstr:=s;
end;
procedure trim(var s : string);
begin
if (s='') then exit;
while (s[1]=' ') do delete(s,1,1);
while (s[length(s)]=' ') do delete(s,length(s),1);
end;
procedure replace(var src : string; torep,rep : string);
var i,j : integer;
begin
i:=pos(torep,src);
if (i>0) then
begin
if (i=1) then
src:=rep+copy(src,length(torep)+1,length(src)-length(torep))
else
src:=copy(src,1,i-1)+rep+copy(src,i+length(torep),length(src)-length(torep)-i+1);
end;
end;
const
variabel : set of char = ['A'..'Z'];
digit : set of char = ['_','0'..'9'] ;
validchar : set of char = ['_','0'..'9','A'..'Z'];
var
value,cv : array ['A'..'Z'] of tint;
function countop(s : string) : integer;
var i,j : integer;
begin
countop:=0; j:=0;
if (s='') then exit;
for i:=1 to length(s) do
if (s
in ['=','+','-','/','*']) then
j:=j+1;
countop:=j;
end;
function subexpr(s:string) : string;
var
i,j,b,f : integer;
d : boolean;
done : boolean;
begin
subexpr:=s;
if (countop(s)=1) then exit; {no sub expression}
if (pos('(',s)>0) then
begin
f:=pos(')',s); {find deepest paranthesis}
b:=1;
for j:=f downto 1 do
if (s[j]='(') then
begin
b:=j;
break;
end;
subexpr:=copy(s,b,f-b+1);
exit;
end;
i:=pos('*',s); {A = 5 * 3 or }
if (i=0) then i:=pos('/',s); {A = 5 + 3 * 6 or}
if (i=0) then i:=pos('+',s); {A = B = 4}
if (i=0) then i:=pos('-',s);
if (i=0) then
begin
for j:=length(s) downto 1 do
if (s[j]='=') then
begin
i:=j;
break;
end;
end;
if (i<>0) then
begin
b:=i-1; f:=i+1;
done:=false; d:=false;
while not done do
begin
if s in validchar then
begin
d:=true;
b:=b-1;
end
else
begin
if d then begin b:=b+1; done:=true; end
else b:=b-1;
end;
if (b=1) then done:=true;
end;
done:=false; d:=false;
while not done do
begin
if s[f] in validchar then
begin
d:=true;
f:=f+1;
end
else
begin
if d then begin f:=f-1; done:=true; end
else f:=f+1;
end;
if (f=length(s)) then done:=true;
end;
subexpr:=copy(s,b,f-b+1);
end;
end;
procedure split(s : string; var opr1,opr2 : string;var oprnd : char);
var
t : string;
i : integer;
m : boolean;
begin
if (s='') then exit;
{remove paranthesis}
if (s[1]='(') then t:=copy(s,2,length(s)-1) else t:=s;
trim(t);
opr1:=''; opr2:='';
i:=1; m:=false;
while (t in variabel) or (t in digit) do
begin
if (t='_') then m:=true
else opr1:=opr1+t;
i:=i+1;
end;
if m then
if (opr1[1] in variabel) then opr1:='_'+opr1
else opr1:='-'+opr1;
while (t=' ') do i:=i+1;
oprnd:=t; i:=i+1;
while (t=' ') do i:=i+1; m:=false;
while ((t in variabel) or (t in digit)) do
begin
if (t[i]='_') then m:=true
else opr2:=opr2+t[i];
i:=i+1;
if (i>length(t)) then break;
end;
if m then
if (opr2[1] in variabel) then opr2:='_'+opr2
else opr2:='-'+opr2;
end;
function getvalue(s : string) : tint;
var
m : boolean;
t : string;
x : tint;
code : integer;
begin
t:=s;
if (t[1]='_') then
begin
m:=true;
delete(t,1,1);
end
else m:=false;
if (t[1] in variabel) then
x:=value[t[1]]
else
val(t,x,code);
if m then x:=-x;
getvalue:=x;
end;
{ B * 2 }
{ 2 * B }
{2 * (B = 7)}
function proceed(s : string) : string;
var
opr1,opr2 : string;
oprnd : char;
a,b : tint;
code : integer;
begin
proceed:='';
split(s,opr1,opr2,oprnd);
{writeln(opr1);
writeln(oprnd);
writeln(opr2);}
b:=getvalue(opr2);
if (oprnd<>'=') then a:=getvalue(opr1);
case oprnd of
'=' : value[opr1[1]]:=b;
'+' : b:=a+b;
'-' : b:=a-b;
'*' : b:=a*b;
'/' : b:=a div b;
end;
if (b<0) then
begin
str(abs(b),opr1);
opr1:='_'+opr1;
end
else
str(b,opr1);
proceed:=opr1;
end;
{calc sub operation -> (op opr op) | (var = op)}
procedure docalc(s : string);
var
t : string;
e,r : string;
c : char;
begin
if (s='') then exit;
t:=s;
move(value,cv,sizeof(value));
while (subexpr(t)<>t) do
begin
e:=subexpr(t);
r:=proceed(e);
{writeln(t,'-->',e,'=',r);}
replace(t,e,r);
{writeln(t);
readkey;}
end;
r:=proceed(t); r:='';
for c:='A' to 'Z' do
begin
if (value[c]<>cv[c]) then
begin
if (r='') then r:=c else write(output,', ');
write(output,c,' = ',value[c]:1);
end;
end;
if (r='') then writeln(output,'No Change') else writeln(output);
end;
var
s : string;
begin
{$IFNDEF ONLINE_JUDGE}
clrscr;
assign(input,infile); reset(input);
assign(output,outfile); rewrite(output);
{$ENDIF}
{---solve problem here---}
fillchar(value,sizeof(value),0);
while not eof(input) do
begin
s:=getstr(input); trim(s);
if (s<>'') then docalc(s);
end;
{---end of problem solving---}
{$IFNDEF ONLINE_JUDGE}
close(output); assign(output,''); rewrite(output);
close(input); assign(input,''); reset(input);
{$ENDIF}
end.
[/pascal]