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;
class Program { static void Main(string[] args) { int n=10; int[] a = new int[n]; int k1=0; int k2=0; int k3=0; Random r = new Random(); Console.WriteLine("Массив a:"); for (int i = 0; i < n; i++) { a[i] = r.Next(41)-20; Console.Write("{0,5}", a[i]); } Console.WriteLine(); for (int i = 0; i < n; i++) { if (a[i]>0) k1++; if (a[i]<0) k2++; if (a[i]==0) k3++; } Console.Write("k1={0} k2={1} k3={2}", k1, k2, k3); Console.ReadKey(); } }