def read_matrix():
line = input()
words =line.split()
n = int(words[0])
m = int(words[1])
mat = []
for i in range(n):
row = []
line = input()
words = line.split()
for j in range(m):
row.append(int(words[j]))
mat.append(row)
return mat
def print_zig_zag(mat):
n = len(mat)
m = len(mat[0])
for i in range(n):
for j in range(m):
jj = j if i%2==0 else m-1-j
print(mat[i][jj], end=' ')
print()
def main():
mat = read_matrix()
print_zig_zag(mat)
if __name__ == '__main__':
main()
Comments
Leave a comment