Procedure sovp; var i, j, r, c: byte; ar: array[1..10, 1..10]of byte; s: array[1..4] of string; b: boolean; label l1; begin r := random(2, 3); l1: c := 1; b := false; for i := 1 to 10 do for j := 1 to 10 do begin ar[i, j] := random(0, 1); if(i < 5) then s[i] := ''; end; for i := 1 to 9 do begin for j := 1 to 10 do begin if(ar[i, j] <> ar[i + 1, j]) then b := true; end; if(b = false) then begin s[c] := i + ' строка совпалает с ' + (i + 1) + ' строкой'; c := c + 1; end; b := false; end; if(c <> r) then goto l1 else begin for var k := 1 to c do if(k<>c)then writeln(s[k]); for i := 1 to 10 do begin for j := 1 to 10 do write(ar[i, j], ' '); writeln; end; end; end; begin sovp; end.
var
i, j, r, c: byte;
ar: array[1..10, 1..10]of byte;
s: array[1..4] of string;
b: boolean;
label l1;
begin
r := random(2, 3);
l1:
c := 1;
b := false;
for i := 1 to 10 do
for j := 1 to 10 do
begin
ar[i, j] := random(0, 1);
if(i < 5) then s[i] := '';
end;
for i := 1 to 9 do
begin
for j := 1 to 10 do
begin
if(ar[i, j] <> ar[i + 1, j]) then b := true;
end;
if(b = false) then
begin
s[c] := i + ' строка совпалает с ' + (i + 1) + ' строкой';
c := c + 1;
end;
b := false;
end;
if(c <> r) then goto l1
else
begin
for var k := 1 to c do if(k<>c)then writeln(s[k]);
for i := 1 to 10 do
begin
for j := 1 to 10 do write(ar[i, j], ' ');
writeln;
end;
end;
end;
begin
sovp;
end.
[0, 0, "a", 1]
[1, 1, "b", 2]
[1, 2, "bb", 3]
[2, 2, "b", 4]
[0, 3, "abba", 5]
[3, 3, "a", 6]
[3, 4, "aa", 7]
[4, 4, "a", 8]
[3, 5, "aaa", 9]
[4, 5, "aa", 10]
[5, 5, "a", 11]
[3, 6, "", 12]
[4, 6, "aaa", 13]
[5, 6, "aa", 14]
[6, 6, "a", 15]
[2, 7, "bb", 16]
[7, 7, "b", 17]
[6, 8, "aba", 18]
[8, 8, "a", 19]
[7, 9, "bab", 20]
[9, 9, "b", 21]
#код программы Ruby 22
s = "abbbab"
n = 0
for r in 0..s.size-1
for l in 0..r
t = s[l..r]
if t.reverse == t
n += 1
p [l,r,t,n]
end
end
end