#include #include typedef struct billet { unsigned short depart; unsigned short arrivee; unsigned short type; } BILLET; typedef enum { ALLER_SIMPLE = 1<<0, PREMIERE = 1<<1, ECHANGEABLE = 1<<2, FUMEUR = 1<<3, SENIOR = 1<<4, ADULTE = 1<<5, JEUNE = 1<<6, ENFANT = 1<<7, BEBE = 1<<8, REDUCTION = 1<<9, SPECIAL = 1<<10, } CRITERE; void billetconstruct (BILLET *construct, char* message[]); int main() { char * message []= {"Aller-simple","Une premiere classe","Billet echangeable",\ "Fumeur","Senior","Adulte ","Jeune","Enfant","Bebe",\ "Reduction particuliere","Situation Speciale"}; BILLET billet1; printf("Indiquez le numero de la ville de depart : "); scanf("%hd", &billet1.depart); printf("Indiquez le numero de laville d'arrivee : "); scanf("%hd", &billet1.arrivee); fflush(stdin); billet1.type=0; billetconstruct(&billet1, message); printf("\n\nRecapitulatif :\nDepart : %d Arrivee : %d \n", billet1.depart, billet1.arrivee); if((billet1.type & ALLER_SIMPLE) != 0) { printf("%s\n", message[0]); } else { printf("Aller-retour\n"); }; return 0; } void billetconstruct (BILLET *construct, char* message[]) { char choix; int i; for(i=0; i<10; i++) { printf("%s ? (o/n) : ", message[i]); choix=getchar(); fflush(stdin); if(choix == 'o') { (*construct).type = (*construct).type ^ (*construct).type[i]; }; } }