Дано 11 чисел. Найти суммычисел кратных 3 и некратных 9.
Program Pr1
var
a: array [1..11] of integer;
i,sum:integer;
begin
sum:=0;
for i:=1 to 11 do
readln(a[i])
if (a[i] mod 3=0) then
sum:=sum+a[i];
writeln(sum);
if (a[i] mod 9<>0) then
end.
Program Pr1;
var a:array [1..11] of integer;
SumCr,SumNeCr,i:integer;
Begin
SumCr:=0;
SumNeCr:=0;
Randomize;
For i:=1 to 11 do
a[i]:=random(100);
Writeln (a[i],' ');
Readln;
If a[i] mod 3 = 0 then SumCr:=SumCr+a[i];
Writeln ('Сумма чисел кратных 3 равна',CumCr);
End;
For I:=1 to 11 do
If a[i] mod 9 <> 0 then SumNeCr:=SumNeCr+a[i];
Writeln ('Сумма чисел не кратных 9 равна',SumNeCr);
End.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Program Pr1
var
a: array [1..11] of integer;
i,sum:integer;
begin
sum:=0;
for i:=1 to 11 do
begin
readln(a[i])
if (a[i] mod 3=0) then
sum:=sum+a[i];
writeln(sum);
sum:=0;
if (a[i] mod 9<>0) then
sum:=sum+a[i];
writeln(sum);
end.
Program Pr1;
var a:array [1..11] of integer;
SumCr,SumNeCr,i:integer;
Begin
SumCr:=0;
SumNeCr:=0;
Randomize;
For i:=1 to 11 do
a[i]:=random(100);
Writeln (a[i],' ');
Readln;
Begin
For i:=1 to 11 do
If a[i] mod 3 = 0 then SumCr:=SumCr+a[i];
Writeln ('Сумма чисел кратных 3 равна',CumCr);
Readln;
End;
Begin
For I:=1 to 11 do
If a[i] mod 9 <> 0 then SumNeCr:=SumNeCr+a[i];
Writeln ('Сумма чисел не кратных 9 равна',SumNeCr);
Readln;
End;
End.