Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include "util.h"
  2.  
  3. int RemoveDuplicates(int arr[], int size)
  4. {
  5.  
  6. int n = 0;
  7. int i, j, count, k;
  8. count = size;
  9.  
  10. // 1,2,1,4,4,3,5,2,1 || 1,2,0,4,0,3,5,0,0
  11.  
  12. for (i = 0; i < size; i++)
  13. {
  14. for (j = i + 1; j < size; j++)
  15. {
  16. if (arr[i] == arr[j])
  17. {
  18.  
  19. for (k = j; k < size; k++)
  20. {
  21. arr[k] = arr[k + 1];
  22.  
  23. }
  24. size--;
  25.  
  26.  
  27.  
  28. }
  29.  
  30. }
  31.  
  32. }
  33.  
  34. while (n < count)
  35. {
  36. printf("%d ", arr[n]);
  37. n++;
  38. }
  39. printf("\n%d", size);
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement