Advertisement
Guest User

ptr-ksk

a guest
Jul 23rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include<malloc>
  2. struct node
  3. {
  4. int value;
  5. struct node *next;
  6. }*heal=NULL;
  7.  
  8. void insert_first(){
  9. struct node *ptr, *ptr1, *ptr2;
  10. ptr=(struct node*)malloc(size of(struct node));
  11. ptr->next=NULL;
  12. if(ptr==NULL)
  13. {
  14. head=ptr;
  15. ptr->next=NULL;
  16. ptr1=head;
  17. }
  18. else
  19. {
  20. ptr->next=head;
  21. head=ptr;
  22. }
  23. printf("value %d",ptr->value);
  24. printf("next add %d",ptr->next);
  25. printf("Own add %d", ptr);
  26.  
  27. main()
  28. {
  29. int i;
  30. for(i=0; i<7; i++)
  31. insert_first();
  32. }
  33. *last
  34. if(head==NULL)
  35. {
  36. head=PTR;
  37. PTR->next=NULL;
  38. PTR1=head;
  39. }
  40. else
  41. {
  42. while(PTR1->next!=NULL)
  43. {
  44. PTR1=PTR1->next;
  45. }
  46. }
  47.  
  48. mid
  49. if(head==NULL)
  50. {
  51. head=PTR;
  52. PTR->next=NULL;
  53. PTR1=head;
  54. pos++;
  55. }
  56. else
  57. {
  58. int i;
  59. for(i=0;i<pos;i++)
  60. {
  61. PTR1=PTR1->next;
  62. }
  63. PTR2=PTR1->next;
  64. PTR1->next=PTR;
  65. PTR->next=PTR2;
  66. pos++;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement