We can use two nested loops. The outer loop picks an element one by one and inner loop checks if the element is present on left side of it. If present, then ignores the element, else prints the element.
C++ Implementation
#include <iostream>
#include <algorithm>
using namespace std;
void printUniqueIntegres(int arr[], int n)
{
// Pick all elements one by one
for (int i=0; i<n; i++)
{
// Check if the picked element is already printed
int j;
for (j=0; j<i; j++)
if (arr[i] == arr[j])
break;
// If not printed earlier, then print it
if (i == j)
cout << arr[i] << " ";
}
}
int main()
{
int arr[] = {6, 10, 15, 14, 19, 1120, 14, 6, 10};
int n = sizeof(arr)/sizeof(arr[0]);
printUniqueIntegres(arr, n);
return 0;
}
Credit: geeksforgeeks