Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void operation(int *array, int length)
- {
- int count =0, i, *current , *end = array + length - 1;
- for ( current = array + 1; array < end; array++, current = array + 1 )
- {
- while ( current <= end )
- {
- if(*current == *array)
- *current = *end--;
- else
- current++;
- }
- count++;
- }
- array -= count;
- printf("The array without dublicates is \n");
- while(array <= end)
- {
- printf("%d\t",*array);
- array++;
- }
- }
- int main()
- {
- int a[100],b[100],l,i;
- printf("Enter the array's limit: ");
- scanf("%d",&l);
- printf("Now enter %d elements.\n",l);
- for(i=0; i<l; i++)
- scanf("%d",&a[i]);
- operation(a,l);
- }
- //Output
- //Enter the array's limit: 5
- //Now enter 5 elements.
- //1
- //2
- //1
- //2
- //8
- //The array without dublicates is
- //1 2 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement