1)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n, sum = 0, k;
cin >> n >> k; //ввести размерность массива и требуемое k
int a[n];
for(int i = 0; i < n; i++) {
cin >> a[i]; //вводим массив
if(a[i]%k == 0) { cout << a[i] << endl; sum+=a[i]; }
}
cout << sum << endl;
}
2)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n, sum = 0, k;
cin >> n;
int a[n], b[n], lenB = 0;
for(int i = 0; i < n; i++) {
cin >> a[i]; //вводим массив
if(a[i] == 0) b[lenB++] = i;
}
for(int i = 0; i < lenB; i++) cout << b[i] << ' ';
cout << endl;
}
450 = <span>111000010 </span>
0000000111000010 - прямой
1111111000111101 - обратный
+1
1111111000111110 - дополнительный
з.ы числа написаны в 2битной сетке (если нужно убери первые нули)
Begin
kk:=0;
for i:=1 to 15 do begin
a[i]:=random(1)+20;
if(a[i]>10)then inc(kk);
end;
end;
from itertools import combinations_with_replacement as comb
def count(arr,num):
res=0
for i in arr:
if (int(i)==num): res+=1
return res
s=''
for i in range(10): s+=str(i)
print(len(list(filter(lambda x: int(x[0])%2==1 and count(x,7)==2 and count(x,2)==0 and count(x,0)==0,list(comb(s,5))))))
Будет выведено 63
var a,b,n:real;
begin
writeln('vvedite chislo');
readln(a);
b=1;
n=b;
while b<a do
begin
if (a mod b = 0) then n:=n*b;
b:=b+2;
end;
writeln('n = ',n);
readln;
end.