Académique Documents
Professionnel Documents
Culture Documents
c########################################
############
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <time.h>
#include <math.h>
#include "gestion.h"
#define DELAI 5
if (*liste == NULL)
{
*liste = nouv_cellule;
}
else
{
Cellule_compagnie* courant = *liste;
while (courant->suivant != NULL)
{
courant = courant->suivant;
}
courant->suivant = nouv_cellule;
}
}
else {
Cellule_avion* courant = *tete;
while (courant->compagnie_suivant != NULL)
{
courant = courant->compagnie_suivant;
}
courant->compagnie_suivant = new_avion;
new_avion->compagnie_precedent = courant;
}
}
if (*tete == NULL) {
*tete = new_compagnie;
}
else {
Cellule_compagnie* courant = *tete;
while (courant->suivant != NULL) {
courant = courant->suivant;
}
courant->suivant = new_compagnie;
}
}
if (strcmp(courant->avion.identifiant, id) == 0)
{
*tete = courant->compagnie_suivant;
if (*tete != NULL)
{
(*tete)->compagnie_precedent = NULL;
}
free(courant);
return;
}
// parcours la liste
while (courant != NULL && strcmp(courant->avion.identifiant, id) != 0)
{
courant = courant->compagnie_suivant;
}
// Suppression de la liste
courant->compagnie_precedent->compagnie_suivant = courant->compagnie_suivant;
if (courant->compagnie_suivant != NULL)
{
courant->compagnie_suivant->compagnie_precedent = courant-
>compagnie_precedent;
}
free(courant);
}
int* get_local_time_plus_five_minutes()
{
time_t t = time(NULL);
struct tm *tm = localtime(&t);
int hour = tm->tm_hour;
int minute = tm->tm_min + 5;
if (minute >= 60)
{
hour++;
minute -= 60;
}
int *time = (int*)malloc(2*sizeof(int));
time[0] = hour;
time[1] = minute;
return time;
}
if (avion_courant->avion.heure_decollage != NULL)
{
num_decollage = num_decollage + 1;
}
else if (avion_courant->suivant_attente != NULL)
{
num_atterrissage = num_atterrissage + 1;
}
avion_courant = avion_courant->compagnie_suivant;
}
printf("Nombre d'avion au decollage: %d\n", num_decollage);
printf("Nombre d'avion a l'atterrissage: %d\n", num_atterrissage);
}
courant = courant->suivant;
}
}
if (strcmp(id, "") == 0)
{
printf("Veuillez entrer le nom de la compagnie: ");
scanf("%s", id);
}
switch (statut)
{
case 'A':
fprintf(aeroport_log, "%s-a-%s-%s-%s\n", id, &statut, H_D, carb_rest,
conso);
break;
case 'U':
fprintf(aeroport_log, "%s-u-%s-%s-%s\n", id, &statut, H_D, carb_rest,
conso);
break;
case 'N':
fprintf(aeroport_log, "%s-n-%s-%s-%s\n", id, &statut, H_D, carb_rest,
conso);
break;
case 'D':
fprintf(aeroport_log, "%s-d-%s-%s-%s\n",id, &statut, H_D, carb_rest,
conso);
break;
case 'C':
fprintf(aeroport_log, "%s-c-%s-%s-%s\n",id, &statut, H_D, carb_rest,
conso);
break;
default:
printf("Statut Indique Invalide\n");
return -1;
}
return 0;
}
######################################Fichier.h####################################
#########################
#ifndef _FILE_H
#define _FILE_H
// Definition de types
typedef Cellule_avion* Liste_avion;
typedef Cellule_compagnie *Liste_compagnie;
//VARIABLES GLOBALES
Liste_compagnie *compagnies;
Liste_avion *avions;
// PROTOTYPES DE FONCTIONS
int* get_local_time_plus_five_minutes();
void Ajout_avion(Liste_avion*, Avion) ;
void Ajout_compagnie(Cellule_compagnie**, Compagnie);
void Supprimer_avion(Liste_avion*, char*);
void Affiche_liste_avion(Liste_avion);
void color(int , int );
int codage_events(char [], FILE *);
void stocker_liste_avion(Cellule_compagnie *);
void Liste_avion_attent_atter(Cellule_avion **, Avion);
void priorite_atterrissage(Liste_avion, char []);
void demande_statut(Liste_compagnie *, char*);
void consulter_historique(Liste_compagnie *,Liste_avion);
void liste_noire_compagnie(Liste_compagnie* , Compagnie);
#endif
#########################################main.c####################################
###############"""
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "gestion.h"
int main()
{
color(10,0);
printf("\t\t\t++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\t\t\t
GESTION DU TRAFIC AERIEN D'UN AEROPORT \n\t\t\t++++++++++++++++++++++++++++++++++
++++++++++++++++++++\n\n");
while(choice != 10)
{
color(15,0);
printf( "\t\t\t\t Veuillez faire votre choix en tapant:\n\n 1 Pour ajouter un
avion au decollage ou a l'atterrissage:\n\n 2 Pour afficher la liste des avions au
decollage:\n\n 3 Pour supprimer un avion au decollage:\n\n 4 Pour decider qu'un
avion en attente devienne proritaire \n\n 5 Pour mettre une compagnie sur la liste
noire\n\n 6 Pour afficher la liste des attentes d'atterrissage\n\n 7 Pour demander
le statut de tous les avions d'une compagnie donnee\n\n 8 Pour consulter
l'historique\n\n 9 Pour le codage des evenements:\n\n 10 pour sortir:\n");
scanf("%d", &choice);
switch (choice)
{
case 1:
while (add_another)
{
// Details des informations sur le nouveau avion
char etat[2];
Avion new_avion;
color(2,0);
printf("Entrer l'identifiant de l'aeronef (6 caracteres):");
scanf("%s", new_avion.identifiant);
printf("Entrer la quantite de carburant(en litre): ");
scanf("%d", &new_avion.carburant);
printf("Entrer la consommation de carburant(en litre): ");
scanf("%d", &new_avion.consommation);
printf("Entrer l'heure de decollage (4 caracteres): ");
scanf("%s", new_avion.heure_decollage);
break;
case 7:
printf("ENTRER L'ACRONYME DE LA COMPAGNIE AERIENNE:");
scanf("%s",acronyme);
demande_statut(&liste_compagnie,acronyme);
break;
case 8:
consulter_historique(&liste_compagnie,liste_avion);
break;
case 9:
aeroport_log = fopen("aeroport.log", "w");
if (aeroport_log == NULL)
{
printf("ERREUR D'OUVERTURE DU FICHIER!\n");
exit(1);
}
//Ajout de trois evenements
aeroport_log = fopen("aeroport.log", "w");
if (aeroport_log == NULL)
{
printf("Erreur d'ouverture du fichier!\n");
exit(1);
}
strcpy(events, "NWA050-A------05-02");
codage_events(events, aeroport_log);
strcpy(events, "ALI122-U------02-01");
codage_events(events, aeroport_log);
fclose(aeroport_log);
break;
case 10:
color(6,0);
printf ("++++++++++++++++++++++++++++++++++MERCI ET A BIENTOT++++
++++++++++++++++++++++++++++++") ;
break;
default:
break;
}
}
return 0;
}