#include <iostream>
using namespace std;
int main()
{
int sum = 0;
int composition = 1;
bool plusSeq = 1;
int n = 0;
cout << "Size array - ";
cin >> n;
int* a = new int[n];
for (int i = 0; i < n; i++)
{
a[i] = -10 + rand() % 21;
sum += a[i];
composition *= a[i];
cout << a[i] << " ";
}
for (int i = 0; i < n; i++)
{
if (a[i] < 0)
a[i] *= a[i];
}
for (int i = 1; i < n; i++)
{
if (a[i] < a[i - 1])
{
plusSeq = 0;
break;
}
}
if (plusSeq)
cout << "\nSum = " << sum;
else
cout << "\nComposition = " << composition;
delete[]a;
return 0;
}
Объяснение:
ответ:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
uses crt;
var i,s:integer;
b:real;
begin
clrscr;
repeat
write('Введите положительное число b=');
readln(b);
until b>0;
i:=1;
s:=0;
while s+i+1<=b do
begin
i:=i+1;
if i mod 2=0 then s:=s+i;
end;
write('Нужно сложить ',i,' чисел, сумма четных=',s);
readln
end.
Объяснение: