fork download
  1. #include <stdio.h>
  2.  
  3. void quickSort(int arr[], int left, int right)
  4. {
  5. int i = left, j = right;
  6. int pivot = arr[(left + right) / 2];
  7. int temp;
  8. do
  9. {
  10. while (arr[i] < pivot)
  11. i++;
  12. while (arr[j] > pivot)
  13. j--;
  14. if (i<= j)
  15. {
  16. temp = arr[i];
  17. arr[i] = arr[j];
  18. arr[j] = temp;
  19. i++;
  20. j--;
  21. }
  22. }
  23. while (i<= j);
  24. {
  25. if (left < j)
  26. quickSort(arr, left, j);
  27.  
  28. if (i < right)
  29. quickSort(arr, i, right);
  30. }
  31. }
  32.  
  33. int main()
  34. {
  35. int i;
  36. int n;
  37. scanf("%d",&n);
  38. int list[300000] = {0,};
  39. int ans[300000] = {0,};
  40. for(i=0;i<n;i++)
  41. {
  42. scanf("%d",&list[i]);
  43. }
  44. quickSort(list, 0, n-1);
  45. for(i=0;i<n;i++)
  46. {
  47. if(i>0)
  48. {
  49. if(list[i]==list[i-1])
  50. {
  51. continue;
  52. }
  53. ans[i]=list[i];
  54. }
  55. }
  56. for(i=0; i<n; i++)
  57. {
  58. if(ans[i]!=0)
  59. printf("%d ", ans[i]);
  60. }
  61. return 0;
  62. }
Success #stdin #stdout 0s 5604KB
stdin
3
1 3 1
stdout
3