-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.py
More file actions
40 lines (28 loc) · 712 Bytes
/
Copy pathMatrix.py
File metadata and controls
40 lines (28 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Given two integers r and c, indicating the number of rows and columns, print a two-dimensional matrix such that the elements of the matrix are in an increasing sequence from 1 to rXc, in a row-major order.
Input Format:
First line of the input contains two space separated integers indicating the rows and columns
Output Format:
Display r lines indicating the elements of the Matrix
Example:
Input:
3 3
Output:
1 2 3
4 5 6
7 8 9
"""
a,b=input().split()
a,b=int(a),int(b)
c=1
for i in range(1,a+1):
for j in range(1,b+1):
if j!=b:
print(c,"",end="")
else:
print(c,end="")
c+=1
if i!=a:
print("")
else:
print("",end="")