Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include<stdio.h> #include #include <conio.h> #define TAILLE 20 typedef struct{ char nom [10]; char prenom [10]; char sexe; float salaire; }t_personne; t_personne fiche [TAILLE]; int nbfiches=-1; /*effacer l'ecran*/ void e_effacer() { system ("cls"); } /*creer une entete*/ void e_entete () { e_effacer(); printf("\n\t projetc"); system ("cls"); printf("\n\t faites vous plaisir"); } /*menu principal*/ void e_principal() { e_entete (); printf ("\n\n\t 1 : ajouter une personne"); printf ("\n\n\t 2 : lister le personnel"); printf ("\n\n\t 3 : quitter"); printf ("\n\n\t\t\t Choix: "); } /*fonction pour ajouter une personne*/ void ajouter_une_personne() { e_entete(); printf("\n promo 20,vivi nous"); printf("\n AJOUTER UNE PERSONNE"); printf("\n NOM: "); scanf("%s",fiche [nbfiches+1].nom); printf("\n PRENOM: "); scanf("%s",fiche [nbfiches+1].prenom); printf("\n SEXE: m ou f: "); scanf("%s",&fiche[nbfiches+1].sexe); printf("\n SALAIRE: "); scanf("%f",&fiche[nbfiches+1].salaire); nbfiches++; } /*fonction lister tout le personnel*/ void lister_tout_le_personnel() { int i=0; if (nbfiches !=0) { for(i;i<=nbfiches;++i) { printf("\n"); printf("\n noms: "); printf("%s",fiche[i].nom); printf("\n prenom: "); printf("%s",fiche[i].prenom); printf("\n salaire: "); printf("%f",fiche[i].salaire); _getch(); } } } /*fonction lister toutes les femmes*/ void lister_toutes_les_femmes() { int i=0;//,choix; for(i;i<=nbfiches;i++) { if(fiche[i].sexe=='f') { printf("\n"); printf("vive nous"); printf("\n noms: "); printf("%s",fiche[i].nom); printf("\n prenom: "); printf("%s",fiche[i].prenom); printf("\n salaire: "); printf("%f",fiche[i].salaire); printf("\n"); _getch(); } } } /*fonction lister tous les hommes*/ void lister_tous_les_hommes() { int i;//,choix; for(i=0;i<=nbfiches;i++) { if(fiche[i].sexe=='m') { printf("\n"); printf("vive nous"); printf("\n noms: "); printf("%s",fiche[i].nom); printf("\n prenom: "); printf("%s",fiche[i].prenom); printf("\n salaire: "); printf("%f",fiche[i].salaire); printf("\n"); _getch(); } } } /*menu secondaire pour lister les gens*/ void e_secondaire() { system ("cls"); int choix; printf ("\n 1 : lister tout le personnel"); printf ("\n 2 : lister toutes les femmes"); printf ("\n 3 : lister tous les hommes"); printf ("\n 4 : retour au menu principal"); printf ("\n\n\t\t\t Choix : "); do { scanf("%d",&choix); switch(choix) { case 1: lister_tout_le_personnel ();break; case 2: lister_toutes_les_femmes ();break; case 3: lister_tous_les_hommes ();break; case 4: e_principal ();break; } } while(choix<1||choix>4); } int main() { int choix; do { do { e_principal (); scanf("%d",&choix); switch(choix) { case 1: ajouter_une_personne (); break; case 2: e_secondaire (); break; case 3: break; } } while (choix<1||choix>3); } while (choix!=3); return (0); }