- 乒乓球
- 2009-02-02 15:52:03 @
program tennis;
var c,q:char;
s,r:array[1..5000] of longint;
i,j,p,m,n,x,i1,y,e,f:longint;
b:boolean;
begin
b:=false;
x:=0;y:=0;i:=0;j:=0;m:=0;n:=0;i1:=0; p:=0;
fillchar(s,sizeof(s),0);
fillchar(r,sizeof(r),0);
while (not eof) and (b=false) do
begin
while (not eoln) and (b=false) do
begin
read(c);
if (p=0) then begin q:=c; inc(p); end;
case c of
'W':begin inc(i);inc(m); end;
'L':begin inc(j);inc(n); end;
'E':b:=true;
end;
inc(i1);
if (i1 mod 20=0) then begin i1:=0;readln;end;
if ((i>=11) and (i-j>=2)) or ((j>=11) and (j-i>=2)) then begin s[x+1]:=i;s[x+2]:=j;x:=x+2;j:=0;i:=0;end;
if ((m>=21) and (m-n>=2)) or ((n>=21) and (n-m>=2)) then begin r[y+1]:=m;r[y+2]:=n;y:=y+2;m:=0;n:=0;end;
end; end;
if (x>=2) then begin for e:=1 to (x div 2) do writeln(s[2*e-1],':',s[2*e]);end;
if (i>=1) or (j>=1) then writeln(i,':',j);
if q='E' then writeln('0:0');
writeln;
if (y>=2) then begin for f:=1 to (y div 2) do writeln(r[2*f-1],':',r[2*f]);end;
if (m>=1) or (n>=1) then writeln(m,':',n);
if q='E' then writeln('0:0');
end.
1 条评论
-
miaoyang LV 8 @ 2014-08-07 10:06:27
var
s:ansistring;
c:char;
w11,l11,w21,l21:longint;
i:longint;
begin
w11:=0; l11:=0; w21:=0; l21:=0;
s:='';
while true do
begin
read(c);
if c='E' then break;
s:=s+c;
end;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(w11);
if s[i]='L' then inc(l11);
if abs(w11-l11)>=2 then
if (w11>=11)or(l11>=11) then begin
writeln(w11,':',l11);
w11:=0; l11:=0;
end;
end;
writeln(w11,':',l11);
writeln;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(w21);
if s[i]='L' then inc(l21);
if abs(w21-l21)>=2 then
if (w21>=21)or(l21>=21) then begin
writeln(w21,':',l21);
w21:=0; l21:=0;
end;
end;
writeln(w21,':',l21);
end.
- 1