n=eval(input())
nn=n
lst=[]
temp=[]
pos=0
m=n*n
row=0
col=0
while n>0:
lst.append([])
string=input().split()
lst[pos]=[eval(x) for x in string]
pos+=1
n-=1
temp.append(lst[row][col])
lst[row][col]=0
m-=1
while m>0:
if (col+1)<nn:
col+=1
if lst[row][col]!=0:
temp.append(lst[row][col])
lst[row][col] = 0
m-=1
while (col-1>=0) and (row+1<nn):
col-=1
row+=1
if lst[row][col] != 0:
temp.append(lst[row][col])
lst[row][col] = 0
m-=1
else:
col+=1
row-=1
break
if (row + 1) < nn:
row += 1
if lst[row][col] != 0:
temp.append(lst[row][col])
lst[row][col] = 0
m -= 1
while (col+1<nn) and (row-1>=0):
col+=1
row-=1
if lst[row][col] != 0:
temp.append(lst[row][col])
lst[row][col] = 0
m-=1
else:
row+=1
col-=1
break
for a in temp:
print(a,end=' ')
CCF--201412-2--z型扫描---python 100分
最新推荐文章于 2021-04-01 09:13:25 发布