Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program selection
- type mass=array [0..1000000] of longint;
- var f: text;
- arr: mass
- procedure sort;
- var
- i, j, nmax,buf:longint;
- begin
- writeln('Введите ', n, ' элементов массива');
- for i := 1 to n - 1 do begin { просмотр массива n-1 раз }
- nmax := i;
- for j := i + 1 to n do { поиск максимума }
- if a[j] > a[nmax] then nmax := j;
- buf := a[i]; { перестановка }
- a[i]:= a[nmax]; { двух }
- a[nmax]:= buf; { элементов массива }
- end;
- begin
- assign(f,'input.txt');
- reset(f);
- read(f,n);
- for i1:=1 to n do
- read(f,a[i1]);
- close(f);
- sort;
- assign(f,'output.txt');`
- rewrite(f);
- for i:=0 to n do
- write(f,a[i],' ');
- close(f);
- readln;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement