SHARE
TWEET

Untitled

a guest Dec 9th, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program mxOut;
  2.  
  3. const N = 10;
  4.  
  5. var a : array[1..N] of integer;
  6.     i, j, mx, cnt, sz : integer;
  7.  
  8. begin
  9.   //Генерируем массив
  10.   for i := 1 to N do
  11.   begin
  12.     a[i] := Random(10);
  13.     write(a[i]);
  14.     write(' ');
  15.   end;
  16.   writeln;
  17.  
  18.   //Находим максимальный элемент
  19.   mx := -999999;
  20.   for i := 1 to N do
  21.   begin
  22.     if a[i] > mx then
  23.     begin
  24.       mx := a[i];
  25.     end;
  26.   end;
  27.   writeln(mx);
  28.  
  29.   //Посчитаем колличество максимальных
  30.   cnt := 0;
  31.   for i := 1 to N do
  32.   begin
  33.     if a[i] = mx then
  34.     begin
  35.       cnt := cnt + 1;
  36.     end;
  37.   end;
  38.  
  39.   //'Удалим' максимальные
  40.   for i := N downto 1 do
  41.   begin
  42.     if a[i] = mx then
  43.     begin
  44.       for j := i to N - 1 do
  45.       begin
  46.         a[j] := a[j + 1];
  47.       end;
  48.     end;
  49.   end;
  50.  
  51.   sz := N - cnt; //Новый размер массива
  52.  
  53.   //Выведем массив
  54.  
  55.   for i := 1 to sz do
  56.   begin
  57.     write(a[i]);
  58.     write(' ');
  59.   end;
  60.  
  61. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top