fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int size;
  8. cin >> size;
  9. int * array = (int *) malloc(size * sizeof(int));
  10. for (int i = 0; i < size; i++) {
  11. cin >> array[i];
  12. }
  13.  
  14. int * pom = (int *) malloc(size * sizeof(int));
  15. int index = 0;
  16. for (int i = 0; i < size; i++) {
  17. int value = array[i];
  18.  
  19. int x = 0;
  20. for (int j = i + 1; j < size; j++) {
  21. if (array[j] == value) {
  22. x++;
  23. break;
  24. }
  25. }
  26. if (x >= 1) {
  27. int boo = 0;
  28. for (int j = 0; j <= index; j++) {
  29. if (pom[j] == value) {
  30. boo = 1;
  31. break;
  32. }
  33. }
  34. if (boo == 0) {
  35. pom[++index] = value;
  36. cout << value;
  37. cout << " ";
  38. }
  39. }
  40. }
  41. free(array);
  42. free(pom);
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 3432KB
stdin
7
1
3
1
8
3
1
45
stdout
1 3