project-python3/lesson2.4_15.py
2025-12-15 14:14:56 +05:00

15 lines
597 B
Python

'''****** Задание ********
*Числовая змейка 2.0.
'''
m, n = int(input()), int(input())
width = len(str(m * n))
for i in range(1, m + 1):
for j in range(n):
if not j % 2 and j != n - 1:
print(str(i + 2 * m * (j // 2)).rjust(width, ' '), end=' ')
elif not j % 2 and j == n - 1:
print(str(i + 2 * m * (j // 2)).rjust(width, ' '))
elif j % 2 and j != n - 1:
print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' '), end=' ')
else:
print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' '))