SHARE
TWEET

Untitled

a guest Jan 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program three;
  2.  
  3. const
  4.     MAXN = 15;
  5.  
  6. var
  7.     a: array[1..MAXN] of integer;
  8.     minpos, maxpos, min, max, i, temp: integer;
  9.  
  10. begin
  11.     minpos := 1;
  12.     min := a[1];
  13.     maxpos := 1;
  14.     max := a[1];
  15.     randomize();
  16.    
  17.     writeln('initial array');
  18.     for i := 1 to MAXN do
  19.     begin
  20.         a[i] := random(900)+100;
  21.         wrtie(a, ' ');
  22.     end;
  23.  
  24.     for i := 1 to MAXN do
  25.     begin
  26.         if a[i] < min then
  27.         begin
  28.             min := a[i];
  29.             minpos := i;
  30.         end;
  31.         if a[i] > max then
  32.         begin
  33.             max := a[i];
  34.             maxpos := i;
  35.         end;
  36.     end;
  37.  
  38.     temp := a[minpos];
  39.     a[minpos] := a[maxpos];
  40.     a[maxpos] := temp;
  41.    
  42.     writeln('reodered array');
  43.     for i := 1 to MAXN do
  44.     begin
  45.         wrtie(a, ' ');
  46.     end;
  47. 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