比赛 |
20100919 |
评测结果 |
AAAAW |
题目名称 |
计算器的改良 |
最终得分 |
80 |
用户昵称 |
gragon |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-09-19 11:36:23 |
显示代码纯文本
- program lkkjzp;
- var
- y,s,st,str:string;
- kx,n,kc,k,z:integer;
- i,j:longint;
- code:integer;
- t:real;
- begin
- assign(input,'computer.in');
- reset(input);
- readln(s);
- close(input);
- assign(output,'computer.out');
- rewrite(output);
- while s<>'' do
- begin
- for i:=1 to length(s) do
- if s[i] in ['a'..'z'] then y:=s[i];
- j:=1;kx:=0;kc:=0;code:=0;
- for i:=1 to pos('=',s) do
- begin
- if ((s[i]='+') or (s[i]='-') or (s[i]='=')) and(i<>1) then
- begin
- str:=copy(s,j,i-j);
- val(str,k,code);
- if code=0 then kc:=kc-k;
- if code<>0 then
- begin
- delete(str,code,1);
- if str='' then k:=1 else
- val(str,k,code);
- if code<>0 then
- if str[1]='+' then k:=1 else if str[1]='-'then k:=-1;
- kx:=kx+k;
- end;
- j:=i;
- end;
- end;
- code:=0;
- j:=pos('=',s)+1;
- for i:=pos('=',s)+1 to length(s) do
- begin
- if ((s[i]='+') or (s[i]='-') and(s[i-1]<>'=')) or (i=length(s)) then
- begin
- if i<> length(s) then str:=copy(s,j,i-j) else str:=copy(s,j,i-j+1);
- val(str,k,code);
- if code=0 then kc:=kc+k;
- if code<>0 then
- begin
- delete(str,code,1);
- if str='' then k:=1 else
- val(str,k,code);
- if code<>0 then
- if str[1]='+' then k:=1 else if str[1]='-'then k:=-1;kx:=kx-k;
- end;
- j:=i;
- end;
- end;
- writeln(y,'=',kc/kx:0:3);
- exit;
- end;
- close(output);
- end.