乒乓球

题意

对于一系列比赛信息的输入(WL形式),输出正确的结果。


分析

如果理解了题目,那么就能做出这题。


var
i,n,x,y:longint;
w:char;
a:array[0..100000]of char;
begin
    n:=0;
    repeat
         read(w);
         if (w='W')or(w='L') then
         begin
             inc(n);
             a[n]:=w;
         end;
    until w='E';
    x:=0;y:=0;
    for i:=1 to n do
    begin
        if a[i]='W' then inc(x);
        if a[i]='L' then inc(y);
        if abs(x-y)>=2 then
        if (x>=11)or(y>=11) then
        begin
            writeln(x,':',y);
            x:=0;y:=0;
        end;
    end;
    writeln(x,':',y);
    writeln;
    x:=0;y:=0;
    for i:=1 to n do
    begin
        if a[i]='W' then inc(x);
        if a[i]='L' then inc(y);
        if abs(x-y)>=2 then
        if (x>=21)or(y>=21) then
        begin
            writeln(x,':',y);
            x:=0;y:=0;
        end;
    end;
    writeln(x,':',y);
end.

posted @ 2017-02-05 18:21  银叶草  阅读(123)  评论(0编辑  收藏  举报
Live2D