Переведите с Phyton на C++ import sys
N = int(sys.stdin.readline())
M = int(sys.stdin.readline())
Map = [["."] * (M + 2)]
for i in range(N):
Map.append(list("." + sys.stdin.readline().rstrip() + '.'))
Map.append(['.'] * (M + 2))
for y in range(1, N + 1):
for x in range(1, M + 1):
if Map[y][x] == '.' and (
Map[y - 1][x] == '#' or Map[y + 1][x] == '#' or
Map[y][x - 1] == '#' or Map[y][x + 1] == '#' or
Map[y - 1][x - 1] == '#' or Map[y - 1][x + 1] == '#' or
Map[y + 1][x - 1] == '#' or Map[y + 1][x + 1] == '#'):
Map[y][x] = '*'
cx = x
cy = y
while True:
sys.stdout.write(str(cy) + ' ' + str(cx) + '\n')
Map[cy][cx] = '.'
for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
if Map[cy + dy][cx + dx] == '*':
cx += dx
cy += dy
break
else:
break

polina1362 polina1362    3   10.12.2021 16:08    0

Другие вопросы по теме Информатика