Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int a[10000]= {0};
- struct node
- {
- int data;
- struct node *next;
- };
- int main()
- {
- struct node *prev,*head,*p;
- int n,i;
- scanf("%d",&n);
- head=NULL;
- for(i=0; i<n; i++)
- {
- p=(struct node*)malloc(sizeof(struct node));
- scanf("%d",&p->data);
- p->next=NULL;
- if(head==NULL)
- {
- head=p;
- }
- else
- {
- prev->next=p;
- }
- prev=p;
- }
- struct node* ptr;
- ptr=head;
- while(ptr!=NULL)
- {
- a[ptr->data]++;
- ptr=ptr->next;
- }
- for(int j=0; j<n; ++j)
- {
- if(a[j]!=0)
- {
- printf("%d ",j);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement