Advertisement
Alex_Fomin

Untitled

Nov 27th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.47 KB | None | 0 0
  1. const n=15;
  2.  
  3. var x:array [1..n] of integer;
  4.     i,index:byte;
  5.     temp:integer;
  6.    
  7. Begin
  8. Writeln('Исходный массив:');
  9. for i:=1 to n do
  10.     Begin
  11.     X[i]:=Random(51)-15;
  12.     Write(X[i]:4);
  13.     end;
  14. Writeln;
  15.  
  16. Index:=1;
  17. for i:=2 to n do if X[Index] > X[i] then Index:=i;
  18.  
  19. Temp:=X[Succ(n div 2)];
  20. X[Succ(n div 2)]:=X[Index];
  21. X[Index]:=Temp;
  22.    
  23. Writeln('Сформированный массив:');
  24. for i:=1 to n do Write(X[i]:4);
  25. Writeln;
  26. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement