I am trying to remove duplicates value in array
sequence is [1, 2, 1, 2, 5]
Program should give output [ 1, 2, 0, 0, 5]
1 == 2
1 == 1 found replace with zero 1 2 0 2 5
1 == 2
1 == 5
2== 1
2 == 2 found replace with zero 1 2 0 0 5
1 == 2
1 == 5
....... and son
I wrote code but struggling with inner loop to update array value
Code:
#include<stdio.h>
int main()
{
int array[5] = { 1, 2, 1, 2, 5};
for ( int i = 0; i < 5; i ++)
{
for ( int j = 0; j < 5; j++)
{
if ( array[i] == array[j+1])
{
}
}
}
for ( int i = 0; i < 5; i ++)
{
printf("%d ", array[i]);
}
return 0;
}