Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. Pre_Flight* create_pre_flights_header_list(void){
  2.  
  3. Pre_Flight *node;
  4. node = (Pre_Flight*) malloc(sizeof(Pre_Flight));
  5.  
  6. if(node != NULL){
  7. ode->airplane.flight_code=0;
  8. node->airplane.init=-1;
  9. node->airplane.takeoff=-1;
  10. node->airplane.eta=-1;
  11. node->airplane.fuel=-1;
  12. node->next = NULL;
  13. }
  14. return node;
  15. }
  16.  
  17. void insert_pre_flight(int fc,int init,int to, int eta, int fuel){
  18. Pre_Flight *node = create_pre_flights_header_list();
  19. Pre_Flight *first;
  20. node->airplane.flight_code = fc;
  21. node->airplane.init = init;
  22. node->airplane.takeoff = to;
  23. node->airplane.eta = eta;
  24. node->airplane.fuel = fuel;
  25.  
  26. if(preflights->next == NULL || node->init < preflights->next->init) {
  27. node->next = preflights->next;
  28. preflights->next = node;
  29. }
  30. else {
  31. first = preflights;
  32. while(first->next != NULL && first->next->init < node->init) {
  33. first = first->next;
  34. }
  35. node->next = first->next;
  36. first->next = node;
  37.  
  38. }
  39. }
  40.  
  41. Pre_Flight* removeInPreFlightList(){
  42. Pre_Flight *tmp = preflights->next;
  43. if(preflights->next == NULL) {
  44. return NULL;
  45. }
  46. else {
  47. if(tmp->next == NULL) {
  48. preflights->next = NULL;
  49.  
  50. }
  51. else {
  52. preflights->next = tmp->next;
  53. tmp->next=NULL;
  54. }
  55. return tmp;
  56. }
  57. }
  58.  
  59. int emptyLists() {
  60. if(preflights->next == NULL && flights->next == NULL) {
  61. return 1;
  62. }else {
  63. return 0;
  64. }
  65. }
  66.  
  67. Flight* create_Flight_header_list(void){
  68.  
  69. Flight *node;
  70. node = (Flight*) malloc(sizeof(Flight));
  71.  
  72. if(node != NULL){
  73. node->currentF.flight_code = fc;
  74. node->currentF.init = init;
  75. node->currentF.takeoff = to;
  76. node->currentF.eta = eta;
  77. node->currentF.fuel = fuel;
  78. node->next = NULL;
  79. }
  80. return node;
  81. }
  82.  
  83. void insert_Flight(int fc,int init,int to, int eta, int fuel){
  84. Flight *node = create_Flight_header_list();
  85. Flight *first;
  86. node->currentF.flight_code = fc;
  87. node->currentF.init = init;
  88. node->currentF.takeoff = to;
  89. node->currentF.eta = eta;
  90. node->currentF.fuel = fuel;
  91.  
  92. if(flights->next == NULL || node->init < flights->next->init) {
  93. node->next = flights->next;
  94. flights->next = node;
  95. }
  96. else {
  97. first = flights;
  98. while(first->next != NULL && first->next->init < node->init) {
  99. first = first->next;
  100. }
  101. node->next = first->next;
  102. first->next = node;
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement