vijos1217 乒乓球

来源:百度知道 编辑:UC知道 时间:2024/06/29 23:58:33
我的程序为什么只能过5个点
program p1217;
var a:array[1..10000000] of char;
i,j,n,p1,p2:longint;
begin
repeat
i:=i+1;
read(a[i]);
until a[i]='E';
n:=i;
i:=0;
repeat
i:=i+1;
if a[i]='W' then p1:=p1+1;
if a[i]='L' then p2:=p2+1;
if (p1=11) and (p1-p2>1) then begin
writeln(p1,':',p2);
p1:=0;
p2:=0;
end;
if (p2=11) and (p2-p1>1) then begin
writeln(p1,':',p2);
p1:=0;
p2:=0;
end;
until i=n;
writeln(p1,':',p2);
p1:=0; p2:=0;
writeln;
i:=0;
repeat
i:=i+1;
if a[i]='W' then p1:=p1+1;
if a[i]='L' then p2:=p2+1;
if (p1=21) and (p1-p2>1) then begin
writeln(p1,':'

题目中有亮点:
乒乓球是一种双人对抗体育项目,每球得分制(即W代表华华得一分,L代表华华对手得一分)。11分制是指,选手双方谁先取得11分,就获得一局比赛的胜利;而21分制指,选手双方谁先取得21分,可以嬴得一局比赛的胜利。当某人分数达到11(11分制)或21(21分制下),但双方的得分差小于两分时(比如21分制下21:20),则比赛继续进行,直到双方差距等于两分为止。请注意,本题中并不考虑一场比赛包含的局数,也就是说一场比赛可能有任意数量的局组成。

但双方的得分差小于两分时(比如21分制下21:20),则比赛继续进行,直到双方差距等于两分为止!

我也是因为这个错了好几次!

附代码:program ex;
var s:array[0..100000] of string;
a1,a2,b1,b2,i,j,k,l,f:longint;
c:char;
begin
i:=1;
while not(eof) do
begin
while not(eoln) do
begin
read(c);
if c='E' then
begin
writeln(a1,':',b1);
s[i]:=s[i]+c;f:=1;break;
end else s[i]:=s[i]+c;
if c='W' then inc(a1);
if c='L' then inc(b1);
if ((a1>=11) and (a1>b1+1)) or ((b1>=11) and (b1>a1+1))then
begin
writel