Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int j,k,n,arr[50],result[50],position=0;
- scanf("%d",&n); //Reading number of elements
- for(j=0;j<n;j++)
- scanf("%d",&arr[j]); //Reading all elements into arr[]
- for(j=0;j<n;j++)
- {
- int found=0; //A variable to keep track if duplicate has been found
- for(k=0;k<j;k++) // Checking all numbers from 0 to our current number
- if(arr[j]==arr[k])
- found=1;
- if(!found)
- result[position++]=arr[j]; //If there are no duplicates of the number, we insert it into array at position and increment position
- }
- for(j=0;j<position;j++)
- printf("%d ",result[j]); //Print the result array
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement