Const n=10;
var a:array[1..n] of integer;
i,s1,s2:integer;
begin
Randomize;
writeln('Массив A:');
for i:=1 to n do
begin
a[i]:=random(51);
write(a[i]:4);
end;
writeln;
s1:=0; s2:=0;
for i:=1 to n do
if i mod 2 = 1 then s1:=s1+a[i] else s2:=s2+a[i];
writeln('s1 = ',s1,' s2 = ',s2);
end.
Пример:
Массив A:
21 46 43 5 40 32 26 34 29 48
s1 = 159 s2 = 165
Подробнее - на Znanija.com -
znanija.com/task/22500151#readmore
Ответ: 1024
using System;
class Program { static void Main(string[] args) { double n = Math.Pow(2.00, 12.00); long howMuch = 0;
SumOfDigits sod = new SumOfDigits(); for (int i = 0; i < n; ++i) { int SumI = sod.CountSumOfDigits(i);
if (SumI % 4 == 0) { howMuch++; } } Console.WriteLine(howMuch); //Console.WriteLine(n); Console.ReadLine(); } } class SumOfDigits { public int CountSumOfDigits(int x) { int sum = 0; while (x > 0) {
sum += x % 10; x /= 10; } return sum; } }
Odt. либроофис, doc. - ворд, txt - блокнот