а вообще, нету смысла искать в инете) Прекол лицея именно в самостоятельном решении и получении навыков
Объяснение:
WHITE = 1
BLACK = 2
def opponent(color):
if color == WHITE:
return BLACK
else:
return WHITE
def correct_coords(row, col):
return 0 <= row < 8 and 0 <= col < 8
class Queen:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
def set_position(self, row, col):
self.row = row
self.col = col
def char(self):
return 'Q'
def get_color(self):
return self.color
def can_move(self, row, col):
if not (0 <= row < 8 and 0 <= col < 8):
return False
if (abs(self.row - row) == abs(self.col - col)) \
or (abs(self.row - row) * abs(self.col - col) == 0):
return True
return False
class Knight:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
def set_position(self, row, col):
self.row = row
self.col = col
def char(self):
return 'N'
def get_color(self):
return self.color
def can_move(self, row, col):
if not (0 <= row < 8 and 0 <= col < 8):
return False
if abs(self.col - col) * abs(self.row - row) == 2 \
and self.row != row and self.col != col:
return True
return False
class Pawn:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
def set_position(self, row, col):
self.row = row
self.col = col
def char(self):
return 'P'
def get_color(self):
return self.color
def can_move(self, row, col):
if not (0 <= row < 8 and 0 <= col < 8):
return False
if self.col != col:
return False
if self.color == WHITE:
direction = 1
start_row = 1
else:
direction = -1
start_row = 6
if self.row + direction == row:
return True
if self.row == start_row and self.row + 2 * direction == row:
return True
return False
class Rook:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
def set_position(self, row, col):
self.row = row
self.col = col
def char(self):
return 'R'
def get_color(self):
return self.color
def can_move(self, row, col):
if not (0 <= row < 8 and 0 <= col < 8):
return False
if self.row != row and self.col != col:
return False
return True
class Bishop:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
def set_position(self, row, col):
self.row = row
self.col = col
def char(self):
return 'B'
def get_color(self):
return self.color
def can_move(self, row, col):
if not (0 <= row < 8 and 0 <= col < 8):
return False
if abs(self.row - row) == abs(self.col - col):
return True
return False
class Board:
def __init__(self):
self.field = []
for row in range(8):
self.field.append([None] * 8)
def current_player_color(self):
return self.color
def cell(self, row, col):
piece = self.field[row][col]
if piece is None:
return ' '
color = piece.get_color()
c = 'w' if color == WHITE else 'b'
return c + piece.char()
def move_piece(self, row, col, row1, col1):
if not correct_coords(row, col) or not correct_coords(row1, col1):
return False
if row == row1 and col == col1:
return False
piece = self.field[row][col]
if piece is None:
return False
if piece.get_color() != self.color:
return False
if not piece.can_move(row1, col1):
return False
self.field[row][col] = None
self.field[row1][col1] = piece
piece.set_position(row1, col1)
self.color = opponent(self.color)
return True
def is_under_attack(self, row, col, color):
for i in range(8):
for j in range(8):
if self.field[i][j] is not None:
piece = self.field[i][j]
if piece.get_color() == color:
if piece.can_move(row, col):
return True
return False
пишем имя программы
Program:chetre;
вводим переменные. для ввода переменных в программе используется тег <var> , который нужен для выделения переменных компьютерных программ
Var
n,i:
после ввода переменных ставим двоеточие и вводим тип данных ,в данном случае это целое или на языке паскаль integer
Var
n,i: integer;
теперь пишем начало
Begin
введём переменную n
Write('n = ');Read(n);
теперь присваиваем значение переменной i
i:=0;
дальше вы наверное всё поймёте
if n div 1000 = n mod 10 then i:=i+1;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if i=1 then Write('Верно')
else Write('Не верно')
End.
вот полная программа без всяких вставок
Рrogram:chetre;
Var
n,i:integer;
Begin
Write('n = ');Read(n);
i:=0;
if n div 1000 = n mod 10 then i:=i+1;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if (n mod 10 = (n div 10) mod 10) then i:=i+1;
n:=n div 10;
if i=1 then Write('Верно')
else Write('Не верно')
End.
Решение.
Выполним действия пользователя в обратном порядке, начиная из С:\учёба\математика\ГИА. Поднимемся на два уровня вверх, окажемся в С:\учёба. Теперь, спустившись на один уровень вниз, мы должны оказаться в каталоге Расписание. Таким образом, исходный каталог имеет полный путь С:\учёба\Расписание.
Правильный ответ указан под номером 3.