Program to remove duplicate elements in an array in C
main()
{
int i,k;int x[10]={5,7,2,8,9,3,3,6,7,20};
k=remove_duplicate(x);
for(i=0;i
}
}
int remove_duplicate(int p[10])
{
int size=10,i,j,k;
for(i=0;i
for(j=0;j
if(i==j)
{
continue;
}
else
if(*(p+i)==*(p+j))
{
k=j;
size--;
while(k < size)
{
*(p+k)=*(p+k+1);
k++;
}
j=0;
}
}
}
return size;
}
No comments
Post a Comment