记录编号 3783 评测结果 AAAAAA
题目名称 打保龄球 最终得分 100
用户昵称 Gravatarfrancis 是否通过 通过
代码语言 Pascal 运行时间 0.012 s
提交时间 2008-10-10 20:17:44 内存使用 0.11 MiB
显示代码纯文本
program bowling;
const
fin='bowling.in';
fou='bowling.out';
var
a:array[0..15,1..2]of longint;
ch:array[1..15,1..2]of char;
m,x,y,n,l,p,i,j:longint;
st:string;
c:char;
f1,f2:text;

procedure init;
begin
assign(f1,fin);
assign(f2,fou);
reset(f1); rewrite(f2);
readln(f1,st);
repeat
 inc(n);
 l:=length(st);
 p:=pos(' ',st);
 if p=2 then begin ch[n,1]:=st[1]; ch[n,2]:=' ';   end;
 if p=3 then begin ch[n,1]:=st[1]; ch[n,2]:=st[2]; end;
 st:=copy(st,p+1,l-p);
until p=0;
 if l=1 then ch[n,1]:=st[1];
 if l=2 then begin ch[n,1]:=st[1]; ch[n,2]:=st[2]; end;
m:=10;
if n<=10 then
 begin
 if (ch[n-1,1]='/')and(ch[n-2,1]='/')and(ch[n,1]='/') then m:=n-2;
 if (ch[n-1,1]='/')and(ch[n,2]='/') then m:=n-1;
 if (ch[n-1,1]='/')and(ch[n,1]<>'/')and(ch[n,2]<>'/') then m:=n-1;
 if (ch[n-1,2]='/') then m:=n-1;
 end;
end;

function num(c:char):longint;
begin
if c='/' then num:=10
         else num:=ord(c)-48;
end;

begin
init;
for i:=1 to m do
begin
 x:=num(ch[i+1,1]);
 if ch[i+1,2]<>' ' then y:=num(ch[i+1,2])
                   else y:=num(ch[i+2,1]);
 if (x<10)and(y=10) then y:=10-x;
 if ch[i,1]='/' then a[i,1]:=10+x+y
   else
    if ch[i,2]='/' then a[i,1]:=10+x else a[i,1]:=num(ch[i,1])+num(ch[i,2]);
 a[i,2]:=a[i-1,2]+a[i,1];
end;
for i:=1 to m-1 do write(f2,a[i,1],' '); writeln(f2,a[m,1]);
for i:=1 to m-1 do write(f2,a[i,2],' '); write(f2,a[m,2]);
close(f1); close(f2);
end.