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/07/13 03:59:41
![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](/uploads/image/z/12868772-68-2.jpg?t=usaco+Broken+Necklace+%E6%B1%82%E6%9F%A5%E9%94%99%2F%2Fusaco+1.1.4+Broken+Necklaceprogram+usaco114%3Bvari%2Cn%2Ctot%2Cmax%3Alongint%3Ba%3Aarray%5B1..1200%5D+of+char%3Bprocedure+init%3Bbeginreadln%28n%29%3Bfor+i%3A%3D1+to+n+do+beginread%28a%5Bi%5D%29%3Ba%5Bi%2Bn%5D%3A%3Da%5Bi%5D%3Ba%5Bi%2Bn%2Bn%5D%3A%3Da%5Bi%5D%3Bend%3Bend%3Bprocedure+xzs%28i%3Ainteger%29%3Bb)
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没有改变,变成死循环