Advertisement
Saleh127

repeat

Feb 28th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int a[10000]= {0};
  4. struct node
  5. {
  6. int data;
  7. struct node *next;
  8. };
  9. int main()
  10. {
  11. struct node *prev,*head,*p;
  12. int n,i;
  13. scanf("%d",&n);
  14. head=NULL;
  15. for(i=0; i<n; i++)
  16. {
  17. p=(struct node*)malloc(sizeof(struct node));
  18. scanf("%d",&p->data);
  19. p->next=NULL;
  20. if(head==NULL)
  21. {
  22. head=p;
  23. }
  24. else
  25. {
  26. prev->next=p;
  27. }
  28. prev=p;
  29. }
  30. struct node* ptr;
  31. ptr=head;
  32. while(ptr!=NULL)
  33. {
  34. a[ptr->data]++;
  35. ptr=ptr->next;
  36. }
  37. for(int j=0; j<n; ++j)
  38. {
  39. if(a[j]!=0)
  40. {
  41. printf("%d ",j);
  42. }
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement