We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b21c7c commit d36bc81Copy full SHA for d36bc81
Python/zigzag.py
@@ -0,0 +1,40 @@
1
+import numpy as np
2
+
3
+rows = int(input("Enter number of rows "))
4
+cols = int(input("Enter number of columns "))
5
+arr = np.zeros([7,16],dtype = int)
6
+num = 0
7
+flag = 0
8
+i = 0
9
+j = 0
10
11
+while j <= cols-1:
12
+ if i<=rows-1 and flag == 0:
13
+ num = num + 1
14
+ arr[i][j] = num
15
+ if i == rows - 1 :
16
+ i = i - 1
17
+ j = j + 1
18
+ flag = 1
19
+ else:
20
+ i = i + 1
21
22
23
+ elif (i<rows-1 and i>=0) and flag == 1:
24
25
26
+ if i == 0:
27
28
29
+ flag = 0
30
31
32
33
34
+for i in range(rows):
35
+ for j in range(cols):
36
+ if(arr[i][j] == 0):
37
+ print(" ",end =" ")
38
39
+ print(arr[i][j],end =" ")
40
+ print()
0 commit comments