SHARE
TWEET

Untitled

Junaid69 Feb 14th, 2020 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. typedef struct Data{
  5.     int a;
  6.     struct Data *next;
  7. }Data;
  8.  
  9. Data *head=NULL;
  10. void insert_at_fast(int n,int x)
  11. {
  12.     Data *new_node  = (Data*)malloc(sizeof(Data));
  13.     new_node -> n = next = temp -> prev;
  14.     new_node -> x = prev = temp;
  15.  
  16.     if (heah -> newnode == next -> temp -> NULL)
  17.  
  18.     temp -> prev = newnode;
  19.     new_node -> next = temp = temp -> next;
  20.  
  21.     Head -> prev -> NULL
  22.     return;
  23. }
  24.  
  25.  
  26. void insert_at_end(int x){
  27.     Data *new_node  = (Data*)malloc(sizeof(Data));
  28.  
  29.     new_node -> a = x;
  30.     new_node -> next = NULL;
  31.  
  32.     Data *temp = head;
  33.     if(head==NULL)
  34.     {
  35.         head=new_node;
  36.         return;
  37.     }
  38.     while(temp -> next != NULL){
  39.         temp = temp -> next;
  40.     }
  41.  
  42.     temp -> next = new_node;
  43.  
  44. }
  45. void insert_at_nth(int n,int x)
  46. {
  47.     Data *newnode=(Data*)malloc(sizeof(Data));
  48.     Data->a=x;
  49.     Data->next=NULL;
  50.     Data *temp=head;
  51.  
  52.     n=n-2;
  53.     while(n--)
  54.     {
  55.         temp=temp->next;
  56.     }
  57.     newnode->next=temp->next;
  58.     temp->next=newnode;
  59. }
  60. void insert_delete_by_value (int n)
  61. {
  62.     Data *newnode=(Data*)malloc(sizeof(Data));
  63.  
  64.     list -> next == temp -> NULL;
  65.     if (head -> next = NULL)
  66.         head = newnode;
  67. }
  68. void insert_delete_by_pos(int n)
  69. {
  70.     Data *newnode=(Data*)malloc(sizeof(Data));
  71.     node *list = heah *temp;
  72.     n=n--2
  73.     while (n--)
  74.     {
  75.       list = list -> next;
  76.       lemp = list -> next;
  77.       list -> next -> temp -> next
  78.     }
  79. }
  80.  
  81. void Print(){
  82.     Data *temp = head;
  83.  
  84.     while(temp != NULL){
  85.         printf("%d ", temp -> a);
  86.         temp = temp -> next;
  87.     }
  88.     printf("\n");
  89. }
  90.  
  91. int main(){
  92.  
  93.     insert_at_end(8);
  94.     insert_at_first(7);
  95.     insert_at_first(6);
  96.     insert_at_first(5);
  97.     Print();
  98.     insert_at_end(8);
  99.     insert_at_end(9);
  100.     Print();
  101.  
  102. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top