usaco Broken Necklace 求查错//usaco 1.1.4 Broken Necklaceprogram usaco114;vari,n,tot,max:longint;a:array[1..1200] of char;procedure init;beginreadln(n);for i:=1 to n do beginread(a[i]);a[i+n]:=a[i];a[i+n+n]:=a[i];end;end;procedure xzs(i:integer);b

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/20 21:36:39
usaco Broken Necklace 求查错//usaco 1.1.4 Broken Necklaceprogram usaco114;vari,n,tot,max:longint;a:array[1..1200] of char;procedure init;beginreadln(n);for i:=1 to n do beginread(a[i]);a[i+n]:=a[i];a[i+n+n]:=a[i];end;end;procedure xzs(i:integer);b

usaco Broken Necklace 求查错//usaco 1.1.4 Broken Necklaceprogram usaco114;vari,n,tot,max:longint;a:array[1..1200] of char;procedure init;beginreadln(n);for i:=1 to n do beginread(a[i]);a[i+n]:=a[i];a[i+n+n]:=a[i];end;end;procedure xzs(i:integer);b
usaco Broken Necklace 求查错
//usaco 1.1.4 Broken Necklace
program usaco114;
var
i,n,tot,max:longint;
a:array[1..1200] of char;
procedure init;
begin
readln(n);
for i:=1 to n do begin
read(a[i]);
a[i+n]:=a[i];
a[i+n+n]:=a[i];
end;
end;
procedure xzs(i:integer);
begin
repeat
if (a[i]=a[i-1]) or (a[i-1]='w') then
tot:=tot+1;
until ((a[i]a[i-1]) and (a[i-1]'w'));
end;
procedure xys(i:integer);
begin
repeat
if ((a[i]=a[i+1]) or (a[i+1]='w')) then
tot:=tot+1;
until ((a[i]a[i+1]) and (a[i+1]'w'));
end;
procedure search;
begin
tot:=0;
max:=0;
for i:=n to 2*n+1 do begin
xys(i);
xzs(i);
if max

usaco Broken Necklace 求查错//usaco 1.1.4 Broken Necklaceprogram usaco114;vari,n,tot,max:longint;a:array[1..1200] of char;procedure init;beginreadln(n);for i:=1 to n do beginread(a[i]);a[i+n]:=a[i];a[i+n+n]:=a[i];end;end;procedure xzs(i:integer);b
procedure xzs(i:integer);
begin
repeat
if (a[i]=a[i-1]) or (a[i-1]='w') then
tot:=tot+1;
until ((a[i]a[i-1]) and (a[i-1]'w'));
end;
procedure xys(i:integer);
begin
repeat
if ((a[i]=a[i+1]) or (a[i+1]='w')) then
tot:=tot+1;
until ((a[i]a[i+1]) and (a[i+1]'w'));
end;
i没有改变,变成死循环