Var m : array[0..6] of Integer; i,k,N : Integer; Begin For i:=0 to 6 do m[i]:=0; Readln(N); k:=6; While N>0 do Begin If N>=Power(2,k) then Begin N:=N-Trunc(Power(2,k)); Inc(m[k]); end else Dec(k); end; For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.'); end.
Еще вариант: Const NN = 7; money : array[1..7] of Integer = (1,2,4,8,16,32,64); Var m : array[1..NN] of Integer; i,k,N : Integer; Begin For i:=1 to NN do m[i]:=0; Readln(N); k:=NN; While N>0 do Begin If N>=money[k] then Begin N:=N-money[k]; Inc(m[k]); end else Dec(k); end; For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.'); end.
1) и 2):
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c = []
for i in range(len(a)):
for j in range(len(b)):
if a[i] == b[j]:
c.append(a[i])
print(list(set(sorted(c # сортировка по возрастанию
print(list(set(sorted(c, reverse=True # сортировка по убыванию
3):
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for elem in a:
if elem < 5:
print(elem,end = ' ')
4)
a = []
for i in range(102):
if i == 100:
a.append(1)
elif i == 101:
a.append(1)
else:
a.append(0)
print(a)
5)
a = []
for i in range(90):
if i % 2 == 0:
a.append(i)
print(a)
print(len(a))
Объяснение:
НА ВЕРНОЕ ВОТ ТАК