Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include <math.h>
- #define MAX_AEROPORTO 200000 //Máximo de Aeroportos que podem existir
- #define MAX_VOO_AERO 150 //Mázimo de Voos por Aeroporto
- #define MAX_VOO 750000 //Máximo de Voos
- #define COD_AERO 3 //Código do Aeroporto
- struct aeroportos
- {
- char codigo_aero[COD_AERO];
- };
- struct voos
- {
- char codigo_aero_p[COD_AERO];
- char codigo_aero_c[COD_AERO];
- int hora;
- int minuto;
- int duracao;
- };
- struct aeroportos aeroporto[MAX_AEROPORTO];
- struct voos voo[MAX_VOO];
- int hashkey_A(int key)
- {
- key = atoi(aeroporto->codigo_aero);
- return key;
- }
- int hashkey_V(int key)
- {
- key = voo->hora*1000 + voo->minuto * 100;
- return key;
- }
- void inserir_A(int key, char codigo_areo[COD_AERO])
- {
- struct aeroportos *aux_aeroporto = (struct aeroportos*) malloc(sizeof(struct aeroportos));
- aux_aeroporto->codigo_aero = codigo_areo;
- int posicao = hashkey_A(key);
- while(aux_aeroporto[posicao]!= NULL && aux_aeroporto[posicao].codigo_aero != -1)
- {
- posicao++;
- posicao % MAX_AEROPORTO;
- printf("+ novo aeroporto %s \n", codigo_areo);
- }
- aux_aeroporto[posicao].codigo_aero = codigo_areo;
- printf("+ aeroporto %s existe \n", codigo_areo);
- }
- void inserir_V(int key, char codigo_aero_p, char codigo_aero_c, int hora, int minuto, int duracao)
- {
- struct voos *aux_voos = (struct voos*) malloc(sizeof(struct voos));
- aux_voos->codigo_aero_c = codigo_aero_c;
- aux_voos->codigo_aero_p = codigo_aero_p;
- aux_voos->hora = hora;
- aux_voos->minuto = minuto;
- aux_voos->duracao = duracao;
- int posicao = hashkey_A(key);
- while(aux_voos[posicao]!= NULL && aux_voos[posicao].codigo_aero_p != -1)
- {
- posicao++;
- posicao % MAX_AEROPORTO;
- printf("+ novo voo %s %s %d:%d \n", codigo_aero_p,codigo_aero_c,hora,minuto);
- }
- aux_voos[posicao].codigo_aero_p = codigo_areo_p;
- printf("+ aeroporto %s existe \n", codigo_areo);
- }
- int main() {
- printf("Hello, World!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement