Commit c2e640b5 authored by RAJAT KAPOOR's avatar RAJAT KAPOOR

Task3

parent b5807599
#!/usr/bin/python
f=open('matrix.txt')
line1=f.readline()
string1=line1
a=list(string1)
r=int(a[0])
c=int(a[2])
x = [[None for _ in range(c)] for _ in range(r)]
t = [[None for _ in range(r)] for _ in range(c)]
l=f.readline()
b=l.split()
for j in range(r):
for i in range(c):
x[j][i] = int(b[i])
l=f.readline()
b=l.split()
f = open('transpose.txt','w')
f.write(str(c))
f.write(' ')
f.write(str(r))
f.write('\n')
for j in range(r):
for i in range(c):
t[i][j]=x[j][i]
for j in range(c):
for i in range(r):
f.write(str(t[j][i]))
f.write(' ')
f.write('\n')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment