Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N = int(input("Введите размер квадрата: "))
- import time, os
- pole = [[0 for _ in range(N)] for _ in range(N)]
- x = N // 2
- y = N // 2
- direction = [-1, 0]
- while x >= 0 and x < N and y >= 0 and y < N:
- if pole[y][x] == 0:
- pole[y][x] = 1
- if direction[0] == -1:
- direction = [0,-1]
- elif direction[0] == 1:
- direction = [0,1]
- elif direction[1] == -1:
- direction = [1,0]
- else:
- direction = [-1,0]
- x += direction[0]
- y += direction[1]
- else:
- pole[y][x] = 0
- if direction[0] == -1:
- direction = [0,1]
- elif direction[0] == 1:
- direction = [0,-1]
- elif direction[1] == -1:
- direction = [-1,0]
- else:
- direction = [1,0]
- x += direction[0]
- y += direction[1]
- for yParse in range(N):
- for xParse in range(N):
- char = ''
- if pole[yParse][xParse] == 0:
- char = 'O'
- else:
- char = 'g'
- print(char, end='')
- print()
- time.sleep(0.5)
- os.system('cls')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement