fork(1) download
  1. Program ChangeMinMax;
  2. Uses Crt;
  3. Var
  4. A : array[1..15] of Integer;
  5. i, minIdx, maxIdx, temp : Integer;
  6. Begin
  7. ClrScr;
  8. Randomize;
  9. For i := 1 to 15 do
  10. Begin
  11. A[i] := Random(100) -(-14);
  12. Write(A[i]:5);
  13. End;
  14. Writeln;
  15. minIdx := 1;
  16. maxIdx := 1;
  17. For i := 2 to 15 do
  18. Begin
  19. if A[i] < A[minIdx] then minIdx := i;
  20. if A[i] > A[maxIdx] then maxIdx := i;
  21. End;
  22. temp := A[minIdx];
  23. A[minIdx] := A[maxIdx];
  24. A[maxIdx] := temp;
  25. For i := 1 to 15 do
  26. Write(A[i]:5);
  27. Writeln;
  28. Readln;
  29. End.
  30.  
  31.  
  32.  
  33.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
   22   44  111   74   70   81  100   81   75   87   67   25   79   63   44
  111   44   22   74   70   81  100   81   75   87   67   25   79   63   44