比赛 20100919 评测结果 AAAAW
题目名称 计算器的改良 最终得分 80
用户昵称 gragon 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-19 11:36:23
显示代码纯文本
  1. program lkkjzp;
  2. var
  3. y,s,st,str:string;
  4. kx,n,kc,k,z:integer;
  5. i,j:longint;
  6. code:integer;
  7. t:real;
  8. begin
  9. assign(input,'computer.in');
  10. reset(input);
  11. readln(s);
  12. close(input);
  13. assign(output,'computer.out');
  14. rewrite(output);
  15. while s<>'' do
  16. begin
  17. for i:=1 to length(s) do
  18. if s[i] in ['a'..'z'] then y:=s[i];
  19. j:=1;kx:=0;kc:=0;code:=0;
  20. for i:=1 to pos('=',s) do
  21. begin
  22. if ((s[i]='+') or (s[i]='-') or (s[i]='=')) and(i<>1) then
  23. begin
  24. str:=copy(s,j,i-j);
  25. val(str,k,code);
  26. if code=0 then kc:=kc-k;
  27. if code<>0 then
  28. begin
  29. delete(str,code,1);
  30. if str='' then k:=1 else
  31. val(str,k,code);
  32. if code<>0 then
  33. if str[1]='+' then k:=1 else if str[1]='-'then k:=-1;
  34. kx:=kx+k;
  35. end;
  36. j:=i;
  37. end;
  38. end;
  39. code:=0;
  40. j:=pos('=',s)+1;
  41. for i:=pos('=',s)+1 to length(s) do
  42. begin
  43. if ((s[i]='+') or (s[i]='-') and(s[i-1]<>'=')) or (i=length(s)) then
  44. begin
  45. if i<> length(s) then str:=copy(s,j,i-j) else str:=copy(s,j,i-j+1);
  46. val(str,k,code);
  47. if code=0 then kc:=kc+k;
  48. if code<>0 then
  49. begin
  50. delete(str,code,1);
  51. if str='' then k:=1 else
  52. val(str,k,code);
  53. if code<>0 then
  54. if str[1]='+' then k:=1 else if str[1]='-'then k:=-1;kx:=kx-k;
  55. end;
  56. j:=i;
  57. end;
  58. end;
  59. writeln(y,'=',kc/kx:0:3);
  60. exit;
  61. end;
  62. close(output);
  63. end.