SHARE
TWEET

Untitled

a guest Feb 21st, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Program selection
  2. type   mass=array [0..1000000] of longint;
  3. var f: text;
  4. arr: mass
  5.  
  6. procedure sort;
  7.   var
  8.  i, j, nmax,buf:longint;
  9.  begin
  10.  
  11.  writeln('Введите ', n, ' элементов массива');    
  12.   for i := 1 to n - 1 do begin      { просмотр массива n-1 раз }        
  13.       nmax := i;        
  14.       for j := i + 1 to n do            { поиск максимума }            
  15.          if a[j] > a[nmax] then nmax := j;            
  16.       buf := a[i];                  { перестановка }            
  17.       a[i]:= a[nmax];             { двух }            
  18.       a[nmax]:= buf;            { элементов массива }        
  19.   end;        
  20.  
  21. begin
  22. assign(f,'input.txt');
  23. reset(f);
  24. read(f,n);
  25. for i1:=1 to n do
  26. read(f,a[i1]);
  27. close(f);
  28. sort;
  29. assign(f,'output.txt');`
  30. rewrite(f);
  31. for i:=0 to n do
  32. write(f,a[i],' ');
  33. close(f);
  34. readln;
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