Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pre_Flight* create_pre_flights_header_list(void){
- Pre_Flight *node;
- node = (Pre_Flight*) malloc(sizeof(Pre_Flight));
- if(node != NULL){
- ode->airplane.flight_code=0;
- node->airplane.init=-1;
- node->airplane.takeoff=-1;
- node->airplane.eta=-1;
- node->airplane.fuel=-1;
- node->next = NULL;
- }
- return node;
- }
- void insert_pre_flight(int fc,int init,int to, int eta, int fuel){
- Pre_Flight *node = create_pre_flights_header_list();
- Pre_Flight *first;
- node->airplane.flight_code = fc;
- node->airplane.init = init;
- node->airplane.takeoff = to;
- node->airplane.eta = eta;
- node->airplane.fuel = fuel;
- if(preflights->next == NULL || node->init < preflights->next->init) {
- node->next = preflights->next;
- preflights->next = node;
- }
- else {
- first = preflights;
- while(first->next != NULL && first->next->init < node->init) {
- first = first->next;
- }
- node->next = first->next;
- first->next = node;
- }
- }
- Pre_Flight* removeInPreFlightList(){
- Pre_Flight *tmp = preflights->next;
- if(preflights->next == NULL) {
- return NULL;
- }
- else {
- if(tmp->next == NULL) {
- preflights->next = NULL;
- }
- else {
- preflights->next = tmp->next;
- tmp->next=NULL;
- }
- return tmp;
- }
- }
- int emptyLists() {
- if(preflights->next == NULL && flights->next == NULL) {
- return 1;
- }else {
- return 0;
- }
- }
- Flight* create_Flight_header_list(void){
- Flight *node;
- node = (Flight*) malloc(sizeof(Flight));
- if(node != NULL){
- node->currentF.flight_code = fc;
- node->currentF.init = init;
- node->currentF.takeoff = to;
- node->currentF.eta = eta;
- node->currentF.fuel = fuel;
- node->next = NULL;
- }
- return node;
- }
- void insert_Flight(int fc,int init,int to, int eta, int fuel){
- Flight *node = create_Flight_header_list();
- Flight *first;
- node->currentF.flight_code = fc;
- node->currentF.init = init;
- node->currentF.takeoff = to;
- node->currentF.eta = eta;
- node->currentF.fuel = fuel;
- if(flights->next == NULL || node->init < flights->next->init) {
- node->next = flights->next;
- flights->next = node;
- }
- else {
- first = flights;
- while(first->next != NULL && first->next->init < node->init) {
- first = first->next;
- }
- node->next = first->next;
- first->next = node;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement