Const n=10; var a:array[1..n] of integer; i,_start,_end, startInd, endInd:integer; begin Randomize; Write('Исходный массив: '); _start:=-1; _end:=-1; startInd:=-1; endInd:=-1;
for i:=1 to n do begin a[i]:=random (0,100); Write(a[i],' '); end; Writeln;
for i:=2 to n do begin if a[i]>a[i-1] then if _start > -1 then _end := i else begin _start := i-1; _end := i; end else begin
if (_start > -1) and ((endInd - startInd) < (_end - _start)) then begin startInd := _start; endInd := _end; end;
_start := -1; _end := -1; end; end;
if startInd > -1 then begin Writeln('Длина диапазона: ', (endInd-startInd+1)); Write('Значения из диапазона: '); for i:=startInd to endInd do Write(a[i],' '); end;
1) #include <iostream>
using namespace std;
int main()
{
double a, b, c;
cin>>a;
cout<<endl;
cin>>b;
cout<<endl;
cin>>c;
cout << "Среднее: " << (a+b+c)/3 << endl;
cout << "Разность: " << 2 * (a + c) - 3 * b << endl;
}
2) #include <iostream>
using namespace std;
int main()
{
int arr[4], max = 0;
for (int i = 0; i < 4; i++)
{
cin >> arr[i];
if(max < arr[i] && arr[i] % 2 == 0)
{
max = arr[i];
}
}
if (!max)
{
cout << "Not found";
}
else
{
cout << "Max: " <<max;
}
}
n=10;
var
a:array[1..n] of integer;
i,_start,_end, startInd, endInd:integer;
begin
Randomize;
Write('Исходный массив: ');
_start:=-1; _end:=-1;
startInd:=-1; endInd:=-1;
for i:=1 to n do
begin
a[i]:=random (0,100);
Write(a[i],' ');
end;
Writeln;
for i:=2 to n do
begin
if a[i]>a[i-1] then
if _start > -1 then _end := i else
begin
_start := i-1;
_end := i;
end
else
begin
if (_start > -1) and ((endInd - startInd) < (_end - _start)) then
begin
startInd := _start;
endInd := _end;
end;
_start := -1;
_end := -1;
end;
end;
if startInd > -1 then
begin
Writeln('Длина диапазона: ', (endInd-startInd+1));
Write('Значения из диапазона: ');
for i:=startInd to endInd do Write(a[i],' ');
end;
end.