llirik

10 элементов: первые 5 по возрастанию, остальные 5 по убыван

Sep 19th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.60 KB | None | 0 0
  1. var a:array[1..10] of integer;
  2. i,j,temp:integer;
  3. begin
  4.     for i:=1 to 10 do
  5.     begin
  6.         a[i] := random(100);
  7.         if i = 6 then write('  |');
  8.         write(a[i]:4);
  9.     end;
  10.    
  11.     writeln;
  12.     for i:=1 to 5 do
  13.     for j:=1 to i do
  14.     begin
  15.         if (a[i] < a[j]) and (i <> j) then
  16.         begin
  17.             temp := a[i];
  18.             a[i] := a[j];
  19.             a[j] := temp;
  20.         end;
  21.     end;
  22.    
  23.     ////////
  24.    
  25.     for i:=6 to 10 do
  26.     for j:=6 to 10 do
  27.     begin
  28.         if (a[i] > a[j]) and (i <> j) then
  29.         begin
  30.             temp := a[i];
  31.             a[i] := a[j];
  32.             a[j] := temp;
  33.         end;
  34.     end;
  35.    
  36.     for i:=1 to 10 do
  37.     begin
  38.         if i = 6 then write('  |');
  39.         write(a[i]:4);
  40.     end;
  41.    
  42. end.
Advertisement
Add Comment
Please, Sign In to add comment