Thursday, December 3, 2009

Efficient code for extracting unique elements from a sorted list of array

int main()
{
int a[10]={1, 2, 4, 4, 7, 8, 9, 14, 14, 20};
int i;
for (i = 0;i<9;i++)
{
if (a[i] != a[i+1])
printf("%d\n",a[i]);
}
return 0;
}

0 comments:

Post a Comment