Var a:array[1..3,1..3] of integer; t:array[0..2] of boolean; k:array[0..2] of integer; i,j:integer; res:boolean;
begin for i := 1 to 3 do for j := 1 to 3 do read(a[i,j]); for i := 0 to 2 do begin k[i] := 0; t[i] := false; end;
for i := 1 to 3 do for j := 1 to 3 do k[a[i,j]] := k[a[i,j]] + 1;
for i := 1 to 3 do begin if (a[i,1] = a[i,2]) and (a[i,2] = a[i,3]) then t[a[i,1]] := true; if (a[1,i] = a[2,i]) and (a[2,i] = a[3,i]) then t[a[1,i]] := true; end; if (a[1,1] = a[2,2]) and (a[2,2] = a[3,3]) then t[a[2,2]] := true; if (a[3,1] = a[2,2]) and (a[2,2] = a[1,3]) then t[a[2,2]] := true;
res := true;
if (k[1] - k[2] > 1) or (k[1] - k[2] < 0) then res := false;
if t[1] and ( t[2] or (k[1] = k[2]) ) then res := false;
if res then writeln('YES') else writeln('NO') end.
Программа: a = input("Введите текущую координату фигуры(вертикаль): ") b = input("Введите текущую координату фигуры(горизонталь): ") c = input("Введите координату для хода(вертикаль): ") d = input("Введите координату для хода(горизонталь): ") # Условие if (a==c) and (b==c): #Конец условия print("Фигура может сделать ход") else: print("Фигура НЕ может сделать ход") Условия: а) if (a==c) and (b==c): #ладья б) if abs(a-c) == abs(b-d): #слон в) if abs(a-c)==1 or abs(b-d)==1: #король г) if abs(a-c) == abs(b-d) or a == c or b == d: #ферзь ж) if((abs(abs(a-c)-2)<0.5) and (abs(abs(b-d)-1)<0.5) or (abs(abs(a-c)-1)<0.5) and (abs(abs(b-d)-2.0)<0.5)): #конь
a:array[1..3,1..3] of integer;
t:array[0..2] of boolean;
k:array[0..2] of integer;
i,j:integer;
res:boolean;
begin
for i := 1 to 3 do
for j := 1 to 3 do
read(a[i,j]);
for i := 0 to 2 do
begin
k[i] := 0;
t[i] := false;
end;
for i := 1 to 3 do
for j := 1 to 3 do
k[a[i,j]] := k[a[i,j]] + 1;
for i := 1 to 3 do
begin
if (a[i,1] = a[i,2]) and (a[i,2] = a[i,3]) then
t[a[i,1]] := true;
if (a[1,i] = a[2,i]) and (a[2,i] = a[3,i]) then
t[a[1,i]] := true;
end;
if (a[1,1] = a[2,2]) and (a[2,2] = a[3,3]) then
t[a[2,2]] := true;
if (a[3,1] = a[2,2]) and (a[2,2] = a[1,3]) then
t[a[2,2]] := true;
res := true;
if (k[1] - k[2] > 1) or (k[1] - k[2] < 0) then
res := false;
if t[1] and ( t[2] or (k[1] = k[2]) ) then
res := false;
if res then
writeln('YES')
else
writeln('NO')
end.