比赛 noip_6 评测结果 C
题目名称 打保龄球 最终得分 0
用户昵称 bly1991 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-26 10:22:14
显示代码纯文本
program bly(input,output);
var
  a:array[1..12,1..2] of char;
  b,c:array[0..12] of integer;
  d,d0:char;
  long:integer;
  i,j:integer;
  f1,f2:text;

  function add(x,y:integer):integer;
  begin
    if a[x,y]='/' then add:=10;
    if a[x,y]=' ' then add:=0;
    if (a[x,y]<>'/')and(a[x,y]<>' ') then add:=ord(a[x,y])-ord('0');
  end;
begin
  assign(f1,'bowling.in');
  reset(f1);
  for i:=1 to 12 do begin
    for j:=1 to 2 do begin
      a[i,j]:=' ';
    end;
  end;
  while not(eof(f1)) do begin
    read(f1,d); read(f1,d0);
    if (d=' ')and(d0<>' ') then begin
      inc(long); a[long,1]:=d0;
      read(f1,d0); a[long,2]:=d0
    end;
    if (d<>' ')and(d0=' ') then begin
      inc(long); a[long,1]:=d;
    end;
    if (d<>' ')and(d0<>' ') then begin
      inc(long); a[long,1]:=d; a[long,2]:=d0;
    end;
  end;
  close(f1);

  for i:=1 to 10 do begin
    if a[i,1]='/' then begin
      b[i]:=b[i]+10;
      if a[i+1,1]='/' then b[i]:=b[i]+10+add(i+2,1);
      if a[i+1,1]<>'/' then begin
        if a[i+1,2]<>'/' then b[i]:=b[i]+add(i+1,1)+add(i+1,2);
        if a[i+1,2]='/' then b[i]:=b[i]+10;
      end;
    end;
    if (a[i,1]<>'/')and(a[i,2]='/') then b[i]:=b[i]+10+add(i+1,1);
    if (a[i,1]<>'/')and(a[i,2]<>'/') then b[i]:=b[i]+add(i,1)+add(i,2);
  end;
  assign(f2,'bowling.out');
  rewrite(f2);
  for i:=1 to 10 do begin
    c[i]:=c[i-1]+c[i]+b[i];
    write(f2,b[i],' ');
  end;
  writeln(f2);
  for i:=1 to 10 do write(f2,c[i],' ');
  close(f2);
end.










end.