fork download
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. const smax=99;
  9. type large=array[0..99] of LongInt;
  10. var data, sort:large; n, i, counter:smallint;
  11.  
  12. procedure swap(Var a, b:LongInt);
  13. var t:LongInt;
  14. begin
  15. t:=a;
  16. a:=b;
  17. b:=t;
  18. end;
  19.  
  20. procedure writeArr(arr:large; n:SmallInt);
  21. Var i:smallint;
  22. begin
  23. for i:=0 to n-1 do write(arr[i], ' ');
  24. Writeln;
  25. end;
  26.  
  27. function difNums(arr:large):large;
  28. Var tArr:large; i, j:SmallInt; isSame:Boolean;
  29. begin
  30. counter := 0;
  31. for i:=0 to n do begin
  32. isSame:=False;
  33. for j:=0 to counter-1 do begin
  34. if arr[i]=tArr[j] then begin
  35. isSame:=True;
  36. end;
  37. end;
  38. if isSame = False then begin
  39. counter := counter + 1;
  40. tArr[counter-1] := arr[i];
  41. end;
  42. end;
  43. difNums := tArr;
  44. end;
  45.  
  46. procedure bubbleSort(Var arr:large; n:smallint);
  47. Var i, j:smallint;
  48. begin
  49. for i:=0 to n do begin
  50. for j:=i to n do begin
  51. if arr[i]>arr[j] then swap(arr[i], arr[j]);
  52. end;
  53. end;
  54. end;
  55.  
  56. begin
  57. read(n);
  58. n:=n-1;
  59. for i:=0 to n do read(data[i]);
  60. sort:=difNums(data);
  61. bubbleSort(sort, counter-1);
  62. Writeln(counter);
  63. writeArr(sort, counter);
  64. end.
Success #stdin #stdout 0s 5284KB
stdin
10
-1 -1 -1 0 0 1 1 0 0 0
stdout
3
-1 0 1