Дан массив натуральных чисел . Найти сумму элементов , кратных заданному К.
Answers & Comments
unicornsi
Program num1; Uses crt; Var a :array [1..100] of integer; i,k,n, s : integer; Begin clrscr; s:=0; write('K=');readln(k); write('N=');readln(n); for i:=1 to n do readln(a[i]); for i:=1 to n do if (a[i] MOD k)=0 then s:=s+a[i]; writeln('S=',s); End.
Answers & Comments
Uses crt;
Var
a :array [1..100] of integer;
i,k,n, s : integer;
Begin
clrscr;
s:=0;
write('K=');readln(k);
write('N=');readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
if (a[i] MOD k)=0 then s:=s+a[i];
writeln('S=',s);
End.