Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #ifndef _COLLATZ_H_
  2. #define _COLLATZ_H_
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdbool.h>
  7.  
  8.  
  9. typedef struct {
  10.     list *first;
  11.     int qty;
  12. } header;
  13.  
  14. typedef struct {
  15.     int val;
  16.     list *next;
  17. } list;
  18.  
  19. typedef header* listADT;
  20.  
  21. listADT
  22. makeList()
  23. {
  24.     listADT ans;
  25.     ans = malloc(sizeof(header));
  26.     ans->first = NULL;
  27.     ans->qty = 0;
  28.     return ans;
  29. }
  30.  
  31. bool
  32. isEmpty(listADT list)
  33. {
  34.     return list->qty==0;
  35. }
  36.  
  37.  
  38. void
  39. addToList(listADT list, int n)
  40. {
  41.     if (list->first == NULL) {
  42.         list->first->val = n;
  43.     }
  44.  
  45.     (algo)
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement