當前位置:編程學習大全網 - 源碼破解 - 2013noip復賽表達式求值

2013noip復賽表達式求值

代碼如下:

program expr;

var

bds:ansistring;

shuzi:array [1..100001] of longint;

zifu:array [0..100000] of char;

k:array [1..50000] of longint;

i,l,n,hehe,j,a,ps:longint;

f:string;

begin

assign(input,*expr.in*);

reset(input);

assign(output,*expr.out*);

rewrite(output);

n:=0;

i:=0;

l:=1;

hehe:=0;

zifu[0]:=*+*;

readln(bds);

while bds<>** do

begin

inc(i);

a:=pos(*+*,bds);

ps:=pos(***,bds);

if ((a > ps) or (a=0)) and (ps<>0) then a:=ps;

f:=bds;

delete(f,a,length(f));

val(f,shuzi[i]);

n:=length(f)+1;

zifu[i]:=bds[n];

delete(bds,1,n);

end;

for j:= 1 to i do

begin

if(zifu[j]=***) and (zifu[j-1]=*+*) then

begin

inc(l);

k[l]:=shuzi[j]*shuzi[j+1];

end

else if (zifu[j]=***) and (zifu[j-1]=***) then k[l]:=k[l]*shuzi[j+1]

else if zifu[j-1]=*+* then

begin

inc(l);

k[l]:=shuzi[j];

end;

end;

for j:= 1 to l do inc(hehe,k[j]);

hehe:=hehe mod 10000;

writeln(hehe);

readln;

close(input);

close(output);

end.

  • 上一篇:公主風炸裂,瞬間成焦點!
  • 下一篇:2013年中央電視臺元旦聯歡晚會有哪些節目?節目列表分別是?
  • copyright 2024編程學習大全網