SeanNers

IntersertionSort

Sep 5th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var
  2. dayso: array[1..100] of Integer;
  3. j, key, k, i, soChuSo: integer;
  4.  
  5. BEGIN
  6. read(soChuSo);
  7. for k:=1 to soChuSo do read(dayso[k]);
  8.  
  9. for i:=2 to soChuSo do begin
  10. key:=dayso[i];
  11. j:=i-1;
  12. while (j > 0) and (dayso[j] > key) do begin
  13. dayso[j+1]:=dayso[j];
  14. j:=j-1;
  15. end;
  16. dayso[j+1]:=key;
  17. end;
  18.  
  19. for k:=1 to soChuSo do write(dayso[k] ,' ');
  20. END.
Advertisement
Add Comment
Please, Sign In to add comment