fork download
  1. program ideone;
  2.  
  3. Const smax = 99;
  4. Type simple = array[0..smax] of smallint;
  5. Var data, res:simple; i, n:smallint;
  6.  
  7. procedure delInArr(Var arr:simple; pos:smallint);
  8. Var i:smallint; tArr:simple;
  9. begin
  10. for i:=0 to pos-1 do tArr[i]:=arr[i];
  11. for i:=pos to smax do tArr[i]:=arr[i+1];
  12. arr:=tArr;
  13. end;
  14.  
  15. procedure insInArr(Var arr:simple; pos, e:smallint);
  16. Var i:smallint; tArr:simple;
  17. begin
  18. for i:=0 to pos-1 do tArr[i]:=arr[i];
  19. tArr[pos]:=e;
  20. for i:=pos+1 to smax do tArr[i]:=arr[i+1];
  21. arr:=tArr;
  22. end;
  23.  
  24. function bubbleSort(arr:simple; n:smallint):simple;
  25. Var i, j, t:smallint;
  26. begin
  27. for i:=0 to n-1 do
  28. for j:=i to n-1 do
  29. if arr[j]<arr[j+1] then begin
  30. t:=arr[j];
  31. arr[j]:=arr[j+1];
  32. arr[j+1]:=t;
  33. end;
  34. bubbleSort:=arr;
  35. end;
  36.  
  37. procedure converter(arr:simple);
  38. Var i:smallint;
  39. begin
  40. end;
  41.  
  42. procedure writeArr(arr:simple; n:smallint);
  43. Var i:smallint;
  44. begin
  45. for i:=0 to n do write(arr[i], ' ');
  46. end;
  47.  
  48. begin
  49. read(n);
  50. n:=n-1;
  51. for i:=0 to n do read(data[i]);
  52. res:=bubbleSort(data, n);
  53. writeArr(res, n);
  54. end.
Success #stdin #stdout 0.01s 5272KB
stdin
7
1 8 4 -1 0 -5 -9
stdout
8 4 1 0 -1 -5 -9