Решения на первый блок

This commit is contained in:
2025-03-25 12:39:42 +03:00
parent 1e61635a97
commit 7f72988d8b
12 changed files with 280 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
1 2
2 3
+38
View File
@@ -0,0 +1,38 @@
a = int(input('Enter a: '))
b = int(input('Enter b: '))
matrix = [
[a, a+1],
[b, b+1]
]
first = True
for line in matrix:
#for el in line:
if first == True:
f_str = f'{line[0]} {line[1]}\n'
first = False
else:
s_str = f'{line[0]} {line[1]}\n'
# Write lines
with open('file', 'w') as f:
f.write(f_str)
f.write(s_str)
f.close()
readed_matrix = []
with open('file', 'r') as f:
for x in f:
if x == '' or x == '\n':
continue
x = x.replace('\n', '')
vals = x.split(' ')
readed_matrix.append(vals)
f.close()
print(f'''
Original matrix:
{matrix}
Readed matrix:
{matrix}
''')