Monday, May 24, 2010

C program to delete duplicate elements in an array?

i want a simple c code to delete duplicate elements in an array

C program to delete duplicate elements in an array?
http://www.google.com/codesearch?q=array...
Reply:assuming your array is x with n elements.





i=0;


while (i%26lt;n-1)


{


j=i+1;


while(j%26lt;n)


{


if (x[i]==x[j])


{


for (int k=j; k%26lt;n-1; k++)


x[k]=x[k+1];





n--


}


j++;


}


i++;


}


No comments:

Post a Comment