N = int(input('Введите N (строки): '))
M = int(input('Введите M (столбцы): '))
array_1 = []
array_2 = []
array_3 = []
el = 0
for i in range(N):
a = []
if M % 2 == 0 and i > 0:
if el == 0:
el = 1
else:
for _ in range(M):
a.append(el)
array_1.append(a)
print('Задание 1.')
for row in array_1:
for el in row:
print(el, end = ' ')
print()
for j in range(N):
if j > i:
a.append(0)
a.append(1)
array_2.append(a)
print('Задание 2.')
for row in array_2:
if j < N - i - 1:
array_3.append(a)
print('Задание 3.')
for row in array_3:
(№ 1328) 1
(№ 1327) -45
Объяснение:
(№ 1328) 1010101_2 - 201_8 + 2D_16
1010101_2 = 1 * 2^6 + 0 * 2^5 + 1 * 2^4 + 0 * 2^3 + 1 * 2^2 + 0 * 2^2 + 1 * 2^0 = 64 + 0 + 16 + 0 + 4 + 0 + 1 = 85_10
201_8 = 2 * 8^2 + 0 * 8^1 + 1 * 8^0 = 128 + 0 + 1 = 129_10
2D_16 = 2 * 16^1 + 13 * 16^0 =32 + 13 = 45_10
85 - 129 + 45 = 1
(№ 1327) 1001101_2 - 261_8 + 37_16
1001101_2 = 1 * 2^6 + 0 * 2^5 + 0 * 2^4 + 1 * 2^3 + 1 * 2^2 + 0 * 2^2 + 1 * 2^0 = 64 + 0 + 0 + 8 + 4 + 0 + 1 = 77_10
261_8 = 2 * 8^2 + 6 * 8^1 + 1 * 8^0 = 128 + 48 + 1 = 177_10
37_16 = 3 * 16^1 + 7 * 16^0 = 48 + 7 = 55_10
77 - 177 + 55 = -45
N = int(input('Введите N (строки): '))
M = int(input('Введите M (столбцы): '))
array_1 = []
array_2 = []
array_3 = []
el = 0
for i in range(N):
a = []
if M % 2 == 0 and i > 0:
if el == 0:
el = 1
else:
el = 0
for _ in range(M):
a.append(el)
if el == 0:
el = 1
else:
el = 0
array_1.append(a)
print('Задание 1.')
for row in array_1:
for el in row:
print(el, end = ' ')
print()
for i in range(N):
a = []
for j in range(N):
if j > i:
a.append(0)
else:
a.append(1)
array_2.append(a)
print()
print('Задание 2.')
for row in array_2:
for el in row:
print(el, end = ' ')
print()
for i in range(N):
a = []
for j in range(N):
if j < N - i - 1:
a.append(0)
else:
a.append(1)
array_3.append(a)
print()
print('Задание 3.')
for row in array_3:
for el in row:
print(el, end = ' ')
print()
(№ 1328) 1
(№ 1327) -45
Объяснение:
(№ 1328) 1010101_2 - 201_8 + 2D_16
1010101_2 = 1 * 2^6 + 0 * 2^5 + 1 * 2^4 + 0 * 2^3 + 1 * 2^2 + 0 * 2^2 + 1 * 2^0 = 64 + 0 + 16 + 0 + 4 + 0 + 1 = 85_10
201_8 = 2 * 8^2 + 0 * 8^1 + 1 * 8^0 = 128 + 0 + 1 = 129_10
2D_16 = 2 * 16^1 + 13 * 16^0 =32 + 13 = 45_10
85 - 129 + 45 = 1
(№ 1327) 1001101_2 - 261_8 + 37_16
1001101_2 = 1 * 2^6 + 0 * 2^5 + 0 * 2^4 + 1 * 2^3 + 1 * 2^2 + 0 * 2^2 + 1 * 2^0 = 64 + 0 + 0 + 8 + 4 + 0 + 1 = 77_10
261_8 = 2 * 8^2 + 6 * 8^1 + 1 * 8^0 = 128 + 48 + 1 = 177_10
37_16 = 3 * 16^1 + 7 * 16^0 = 48 + 7 = 55_10
77 - 177 + 55 = -45