SHARE
TWEET

Untitled

a guest Oct 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.  
  4. struct LinkedList
  5. {
  6.     int data;
  7.     struct LinkedList *next;
  8. };
  9.  
  10. void addValue(struct LinkedList *, int val);
  11. void addItem(struct LinkedList *,struct LinkedList *);
  12.  
  13.  
  14.  
  15. int main(){
  16.     struct LinkedList start;
  17.     start.data = 1;
  18.     start.next = NULL;
  19.     printf("%d",start.data);
  20.  
  21.     for(int i=0;i<10;i++){
  22.         addValue(&start, i*i);
  23.         addItem(&start,&newItem);
  24.     }
  25.  
  26.     return 0;
  27. }
  28.  
  29. void addItem(struct LinkedList *list,struct LinkedList *item){
  30.     while(list->next != NULL)
  31.         list = list->next;
  32.     list->next = item;
  33. }
  34.  
  35. void addValue(struct LinkedList *list, int val){
  36.     struct LinkedList newItem;
  37.     newItem.data = val;
  38.     newItem.next = NULL;
  39.     addItem(list, &newItem);
  40. }
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