Susri

Untitled

Feb 7th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. typedef struct Node{
  5. int data;
  6.  struct Node *ptr;
  7. }single;
  8. void insert(single *pointer,int data)
  9. {
  10.     while(pointer->ptr!=NULL)
  11.     {
  12.         pointer=pointer->ptr;
  13.     }
  14.     pointer->ptr=(single*)malloc(sizeof(single));
  15.     pointer=pointer->ptr;
  16.     pointer->data=data;
  17.     pointer->ptr=NULL;
  18. }
  19. int main()
  20. {
  21.     while(1)
  22.     {
  23.         int q,data;
  24.         scanf("%d",&q);
  25.         switch(q)
  26.         {case 1:
  27.             scanf("%d",&data);
  28.             insert(start,data);
  29.  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment