Advertisement
AmidamaruZXC

Task

Mar 21st, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.73 KB | None | 0 0
  1. var
  2.   A, B: array of real;
  3.   i, n, count: integer;
  4.   max: real;
  5.  
  6. begin
  7.   write('Введите размер массива A: ');
  8.   readln(n);
  9.   count := 0;
  10.   max := -1;
  11.   SetLength(A, n);
  12.   for i := 0 to n - 1 do
  13.   begin
  14.     write('Введите A[', i, ']: ');
  15.     readln(A[i]);
  16.     if (A[i] > 0) then
  17.       count += 1;
  18.   end;
  19.   SetLength(B, count);
  20.   count := 0;
  21.   for i := 0 to n - 1 do
  22.   begin
  23.     if (A[i] > 0) then
  24.     begin
  25.       B[count] := A[i];
  26.       count += 1;
  27.       if (A[i] > max) then
  28.         max := A[i];
  29.     end;
  30.   end;
  31.   write('Массив B: ');
  32.   for i := 0 to count - 1 do
  33.     write(B[i], ' ');
  34.   writeln();
  35.   write('Наибольший элемент массива B: ', max);
  36. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement