Herilalaina Rakotoarison
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Heri: ```cpp void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ int ind; bool ajoutOK = true; if (EC.nbP == MAXPERSONNES) { ajoutOK = false; cout << "La base est pleine, on ne peut pas ajouter une personne." << endl; } else { for (int i = 0; i < EC.nbP; i++) // interdire l'homonymie if (EC.tableP[i].nom == sonNom) { ajoutOK = false; cout << "La personne " << sonNom << " existe deja dans la base." << endl; break; } if (ajoutOK == true) { ind = EC.nbP; EC.tableP[ind].nom = sonNom; EC.tableP[ind].genre = s; EC.tableP[ind].indConjoint = -1; // pas de conjoint EC.tableP[ind].indParent1 = parent1; EC.tableP[ind].indParent2 = parent2; EC.nbP++; // mise a jour du nombre de personnes } } } ``` Julien : ```cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; #define ASSERT(test) if (!(test)) std::cout << "Test failed in file " << __FILE__ \ << " line " << __LINE__ << ": " #test << std::endl const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ bool ajout = true; if (EC.nbP == MAXPERSONNES){ cout << "La base de données est pleine, on ne peut ajouter personne" << endl; } else if (parent1 >= -1 and parent1 < 50 and parent2 >= -1 and parent2 < 50){ cout << "Vérifiez les données parentales" << endl; } else if (sonNom.size()>20){ cout << "Le nom entré est trop long, merci de corriger" << endl; } else { for (int i = 0; i <EC.nbP; i++){ if (sonNom == EC.tableP[i].nom){ cout << "Une personne a déjà ce nom, ajout impossible" << endl; ajout = false; break; } } if (ajout){ EC.tableP[EC.nbP].nom = sonNom; EC.tableP[EC.nbP].genre = s; EC.tableP[EC.nbP].indParent1 = parent1; EC.tableP[EC.nbP].indParent2 = parent2; EC.tableP[EC.nbP].indConjoint = -1; EC.nbP ++; } } } void AffichePersonne(int ind, EtatCivil EC){ if (EC.tableP[ind].genre == M){ cout << EC.tableP[ind].nom << " est un homme"; } else { cout << EC.tableP[ind].nom << " est une femme"; } if (EC.tableP[ind].indConjoint >= 0){ cout << " qui est marié à " << EC.tableP[EC.tableP[ind].indConjoint].nom; } if (EC.tableP[ind].indParent1 >= 0){ cout << " qui a pour parent " << EC.tableP[EC.tableP[ind].indParent1].nom; } if (EC.tableP[ind].indParent2 >= 0){ if (EC.tableP[ind].indParent1 >= 0) cout << " et "; else cout << " qui a pour parent "; cout << EC.tableP[EC.tableP[ind].indParent2].nom; } cout << endl; } void AfficheEtatCivil(EtatCivil EC){ for (int i = 0; i < EC.nbP; i++){ AffichePersonne(i,EC); } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int recherchePersonne (EtatCivil EC, string nom){ int r = -1; for (int i = 0; i < MAXPERSONNES; i++){ if (EC.tableP[i].nom == nom) r = i; } return r; } bool mariage(string nom1, string nom2, EtatCivil &EC){ int p1 = recherchePersonne(EC, nom1); int p2 = recherchePersonne(EC, nom2); bool res = false; if (p1 >= 0 && p2 >= 0){ if (EC.tableP[p1].indConjoint < 0 && EC.tableP[p2].indConjoint < 0){ EC.tableP[p1].indConjoint = p2; EC.tableP[p2].indConjoint = p1; res = true; } } return res; } void arbre (int nb, int indice, EtatCivil EC){ for (int i = 0; i < indice; i++){ cout << " |"; } if (nb >= 0){ cout << EC.tableP[nb].nom << endl; indice++; arbre (EC.tableP[nb].indParent1, indice, EC); arbre (EC.tableP[nb].indParent2, indice, EC); } else { cout << "Inconnu" << endl; } } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); AjoutPersonne("Jean",M,-1,-1, EC); AjoutPersonne("Jeanne",F,-1,-1,EC); AfficheEtatCivil(EC); cout << endl; AffichePersonne(recherchePersonne(EC,"Luc"),EC); mariage("Jean","Jeanne",EC); AffichePersonne(recherchePersonne(EC,"Jean"),EC); AffichePersonne(recherchePersonne(EC,"Jeanne"),EC); cout << endl; arbre (8, 0, EC); } ``` Corntin : ``` cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ bool a = true; for(int i = 0; i < EC.nbP; i++){ if(sonNom == EC.tableP[i].nom){ cout<<"Nom deja utilise"<<endl; a = false; } } if(EC.nbP < MAXPERSONNES and a){ EC.tableP[EC.nbP] = {sonNom, s, -1, parent1, parent2}; EC.nbP++; }else{ cout<<"Impossible de rajouter cette personne"<<endl; } } void AffichePersonne(int ind, EtatCivil EC){ cout<<"Nom : "<<EC.tableP[ind].nom<<endl; cout<<"Genre : "; if(EC.tableP[ind].genre == M){ cout<<"Homme"<<endl; }else if(EC.tableP[ind].genre == F){ cout<<"Femme"<<endl; }else{ cout<<"Non Binaire"<<endl; } cout<<"Indice du conjoint : "<<EC.tableP[ind].indConjoint<<endl; cout<<"Indice du parent 1 : "<<EC.tableP[ind].indParent1<<endl; cout<<"Indice du parent 2 : "<<EC.tableP[ind].indParent2<<endl; } void AfficheEtatCivil(EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ AffichePersonne(i, EC);cout<<endl; } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int recherchePersonne(string nomP, EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ if(EC.tableP[i].nom == nomP){ return i; } } return -1; } bool mariage(string nom1, string nom2, EtatCivil &EC){ int P1 = recherchePersonne(nom1, EC); int P2 = recherchePersonne(nom2, EC); if(P1 != -1 and P2 != -1){ if(EC.tableP[P1].indConjoint == -1 and EC.tableP[P2].indConjoint == -1){ EC.tableP[P1].indConjoint = P2; EC.tableP[P2].indConjoint = P1; return true; } } return false; } void arbreGenealogique(int indiceP, EtatCivil EC, int compteur){ for(int i = 0; i < compteur; i++){ cout<<" "; } cout<<"Individu "<<indiceP<<endl; if(EC.tableP[indiceP].indParent1 == -1){ for(int i = 0; i < compteur+1; i++){ cout<<" "; } cout<<"Individu Inconnu"<<endl; }else{ arbreGenealogique(EC.tableP[indiceP].indParent1, EC, compteur + 1); } if(EC.tableP[indiceP].indParent2 == -1){ for(int i = 0; i < compteur+1; i++){ cout<<" "; } cout<<"Individu Inconnu"<<endl; }else{ arbreGenealogique(EC.tableP[indiceP].indParent2, EC, compteur + 1); } } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); arbreGenealogique(9, EC, 0); } ``` Fabrice : ```cpp #include <cstdlib> #include <iostream> #include <string> const int MAXPERSONNES = 50; enum Genre { M, F }; char charGenre(Genre const& s) { if (s == F) return 'F'; else return 'M'; } struct Personne{ std::string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP = 0; }; void AjoutPersonne(std::string sonNom, Genre s, int parent1, int parent2, EtatCivil& EC) { if (EC.nbP + 1 >= MAXPERSONNES) throw("Il y a trop de gens !"); EC.tableP[EC.nbP] = {sonNom, s, -1, parent1, parent2}; EC.nbP++; } void AffichePersonne(int ind, EtatCivil const& EC) { if (ind >= EC.nbP) throw("Je ne connais pas cette personne !"); std::cout << EC.tableP[ind].nom << " (" << charGenre(EC.tableP[ind].genre) << ")" << std::endl; } void AfficheEtatCivil(EtatCivil const& EC) { for (int i = 0; i < EC.nbP; i++) AffichePersonne(i, EC); } void RemplitEtatCivil(EtatCivil& EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int indexPersonne(EtatCivil const& EC, std::string nom) { for (int i = 0; i < EC.nbP; i++) if (EC.tableP[i].nom == nom) return i; return -1; } void mariage(EtatCivil& EC, std::string nom1, std::string nom2) { int id1 = indexPersonne(EC, nom1); int id2 = indexPersonne(EC, nom2); if (id1 == -1 || id2 == -1) std::cout << "Impossible de faire un mariage avec quelqu'un qui n'existe pas !" << std::endl; else { Personne pers1 = EC.tableP[id1]; Personne pers2 = EC.tableP[id2]; if (pers1.indConjoint != -1 || pers2.indConjoint != -1) std::cout << "Le mariage multiple n'est pas autorisé !" << std::endl; else { pers1.indConjoint = id2; pers2.indConjoint = id1; } } } void arbreGenealogique(EtatCivil const& EC, int id, int tabs = 0) { if (id == -1) return; if (id >= EC.nbP) { std::cout << "Je ne connais pas cette personne !" << std::endl; return; } std::string espaces = ""; for (int i = 0; i < tabs; i++) espaces += " "; Personne pers = EC.tableP[id]; std::cout << espaces << pers.nom << std::endl; arbreGenealogique(EC, pers.indParent1, tabs+1); arbreGenealogique(EC, pers.indParent2, tabs+1); } int main() { EtatCivil EC; RemplitEtatCivil(EC); AfficheEtatCivil(EC); arbreGenealogique(EC, 9); //EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes } ``` Colin : ```cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ Personne p; p.nom = sonNom; p.genre = s; p.indParent1 = parent1; p.indParent2 = parent2; bool ok = true; if (EC.nbP == MAXPERSONNES){ cout << "Il y a déjà trop d'utilisateurs"; ok = false; } else { for (int i = 0; i < EC.nbP; i++){ if(EC.tableP[i].nom == sonNom){ ok = false; cout << "Utilisateur déjà enregistré"; } } if (ok) { EC.tableP[EC.nbP + 1] = p; EC.nbP++; } } } void AffichePersonne(int ind, EtatCivil EC){ if (ind > MAXPERSONNES){ cout << "L'indice donné ne convient pas" << endl; } else if (EC.tableP[ind].nom == ""){ cout << "La personne n'existe pas" << endl; } else { cout << "Prénom :" << EC.tableP[ind].nom << endl; if (EC.tableP[ind].genre == M){ cout << "Genre : Homme" << endl; } else { cout << "Genre : Femme" << endl; } if (EC.tableP[ind].indParent1 != -1){ cout << "Parent 1 :" << EC.tableP[EC.tableP[ind].indParent1].nom << endl; } else { cout << "Nous n'avons pas l'information du premier parent" << endl; } if (EC.tableP[ind].indParent2 != -1){ cout << "Parent 2 :" << EC.tableP[EC.tableP[ind].indParent2].nom << endl; } else { cout << "Nous n'avons pas l'information du second parent" << endl; } } } void AfficheEtatCivil(EtatCivil EC){ for (int i = 0; i < EC.nbP; i++){ AffichePersonne(i, EC); } } int chercheIdentifiant(string name, EtatCivil EC){ for (int i = 0; i < EC.nbP; i++){ if (EC.tableP[i].nom == name){ return i; } } return -1; } bool mariage(EtatCivil &EC, string nom1, string nom2){ for (int i = 0; i < EC.nbP; i++){ if (EC.tableP[i].nom == nom1){ for (int j = 0; j < EC.nbP; j++){ if (EC.tableP[j].nom == nom2){ if (EC.tableP[j].indConjoint == i){ return false; } EC.tableP[j].indConjoint = i; EC.tableP[i].indConjoint = j; return true; } } } } return false; } void arbreGenealogique(EtatCivil EC, int id, int tab = 0){ string spaces = ""; for (int i = 0; i < tab; i++){ spaces += " "; } if (id != -1){ cout << spaces << EC.tableP[id].nom << endl; } else { cout << spaces << "Individu inconnu" << endl;} arbreGenealogique(EC, EC.tableP[id].indParent1, tab+2); arbreGenealogique(EC, EC.tableP[id].indParent2, tab+2); } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); AfficheEtatCivil(EC); return 0; } ``` pelouse : ```cpp #include <cstdlib> #include <iostream> #include <string> #include <iomanip> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ Personne p; p.nom = sonNom; p.genre = s; p.indConjoint = -1; p.indParent1 = parent1; p.indParent2 = parent2; if(EC.nbP == 50){ cout<<"erreur 430, plus de place"<<endl; return; } EC.tableP[EC.nbP] = p; EC.nbP++; } void AffichePersonne(int ind, EtatCivil EC){ if(ind > EC.nbP){ cout<<"error 404, not found"<<endl; return; } Personne p = EC.tableP[ind]; cout<<p.nom<<" est de sexe "<<p.genre<<endl; if(p.indConjoint > -1) cout<<"son conjoint est "<<EC.tableP[p.indConjoint].nom<<endl; if(p.indParent1 > -1) cout<< "un de ses parents est "<<EC.tableP[p.indParent1].nom<<endl; if(p.indParent2 > -1) cout<< "l'autre est "<<EC.tableP[p.indParent2].nom<<endl; cout<<endl; } void AfficheEtatCivil(EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ AffichePersonne(i,EC); } } int rechercheNom(string nom, EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ if(EC.tableP[i].nom == nom) return i; } return -1; } bool mariage(string nom1, string nom2, EtatCivil &EC){ if(EC.tableP[rechercheNom(nom1,EC)].indConjoint == -1 && EC.tableP[rechercheNom(nom2,EC)].indConjoint == -1){ EC.tableP[rechercheNom(nom1,EC)].indConjoint = rechercheNom(nom2,EC); EC.tableP[rechercheNom(nom2,EC)].indConjoint = rechercheNom(nom1,EC); return true; } return false; } void arbreGenial(int ind, EtatCivil EC, int i){ cout<<EC.tableP[ind].nom<<endl; for(int j = 0; j <= i; j++){ cout<<" "; } if (EC.tableP[ind].indParent1 == -1) cout<<"Inconnu"<<endl; else arbreGenial(EC.tableP[ind].indParent1, EC, i+1); for(int j = 0; j <= i; j++){ cout<<" "; } if (EC.tableP[ind].indParent2 == -1) cout<<"Inconnu"<<endl; else arbreGenial(EC.tableP[ind].indParent2, EC, i+1); } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 8, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, 9, 14, EC); AjoutPersonne("Viviane", F, 0, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); arbreGenial(rechercheNom("John",EC),EC,0); } ``` Axel : ```cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC) { Personne newP; newP.nom = sonNom; newP.genre = s; newP.indConjoint = -1; newP.indParent1 = parent1; newP.indParent2 = parent2; if (EC.nbP >= MAXPERSONNES) cout << "erreur, plus de place"; else { EC.tableP[EC.nbP] = newP; EC.nbP++; cout << newP.nom << " a bien ete rajoute dans l'etat civil bg" << endl; } } int recherchePersonne(string nom, EtatCivil EC) { for(int i=0; i<EC.nbP; i++){ if (EC.tableP[i].nom == nom) return i; } return -1; } void AffichePersonne(int ind, EtatCivil EC) { if (ind > EC.nbP) cout << "Y'a pas la personne dedans :c" << endl; else { Personne guy; cout << "Nom : " << EC.tableP[ind-1].nom << endl; cout << "Genre : "; if (EC.tableP[ind].genre == M) cout << "M"; else cout << "F"; cout << endl; cout << "indice du conjoint : " << EC.tableP[ind-1].indConjoint << endl; cout << "indice du parent 1 : " << EC.tableP[ind-1].indParent1 << endl; cout << "indice du parent 2 : " << EC.tableP[ind-1].indParent2 << endl; } } void AfficheEtatCivil(EtatCivil EC) { for(int i=1; i<=EC.nbP; i++) { AffichePersonne(i, EC); cout << endl; } } bool setMariage(int p1, int p2, EtatCivil &EC) { if((EC.tableP[p1].indConjoint != -1 || EC.tableP[p2].indConjoint != -1) || (p1 >= EC.nbP || p2 >= EC.nbP) || p1 == p2){ cout << "Erreur, mariage pas possible"; return false; } else { EC.tableP[p1].indConjoint = p2; EC.tableP[p2].indConjoint = p1; cout << "mariage effectue!" << endl; return true; } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } void genealogie(int ind, int i, EtatCivil EC) { for (int j=0; j<i; j++){ cout << " "; } if (ind == -1){ cout << "Individu inconnu" << endl; } else { cout << EC.tableP[ind].nom << endl; int papa = EC.tableP[ind].indParent1; int maman = EC.tableP[ind].indParent2; genealogie(papa, i+1, EC); genealogie(maman, i+1, EC); } } int main() { EtatCivil EC; EC.nbP = 0; /// il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); cout << endl << endl; AfficheEtatCivil(EC); cout << recherchePersonne("Boris", EC) << endl; setMariage(2, 5, EC); genealogie(10, 0, EC); } ```` Bernard : ```cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ int t = 0; for (int i = 0; i < MAXPERSONNES; i++){ if (EC.tableP[i].nom != ""){ t = t + 1; } } if (t >= MAXPERSONNES){ cout << "Il est impossible d'ajouter une personne dans l'état civil" << endl; }else{ EC.tableP[t].nom = sonNom; EC.tableP[t].genre = s; EC.tableP[t].indConjoint = -1; EC.tableP[t].indParent1 = parent1; EC.tableP[t].indParent2 = parent2; EC.nbP = EC.nbP + 1; } } void AffichePersonne(int ind, EtatCivil EC){ if (EC.tableP[ind].nom != ""){ cout << "Nom : " << EC.tableP[ind].nom << endl; if (EC.tableP[ind].genre == 0){ cout << "Genre : " << "M" << endl; } if (EC.tableP[ind].genre == 1){ cout << "Genre : " << "F" << endl; } cout << "Conjoint : " << EC.tableP[ind].indConjoint << endl; cout << "Parent 1 : " << EC.tableP[ind].indParent1 << endl; cout << "Parent 2 : " << EC.tableP[ind].indParent2 << endl; }else{ cout << "Cette personne n'existe pas" << endl; } } void AfficheEtatCivil(EtatCivil EC){ for (int i = 0; i < MAXPERSONNES; i++){ if (EC.tableP[i].nom != ""){ AffichePersonne(i, EC); } } } int trouvePersonne(string sonNom, EtatCivil EC){ for (int i = 0; i < MAXPERSONNES; i++){ if (EC.tableP[i].nom == sonNom){ return i; } } return -1; } bool mariage(string Nom1, string Nom2, EtatCivil EC){ if (trouvePersonne(Nom1, EC) != -1 and trouvePersonne(Nom2, EC) != -1){ for (int i = 0; i < MAXPERSONNES; i++){ if (EC.tableP[i].nom == Nom1){ for (int j = 0; j < MAXPERSONNES; j++){ if (EC.tableP[j].nom == Nom2){ if (EC.tableP[i].indConjoint == -1 and EC.tableP[j].indConjoint == -1){ return true; } } } } } } return false; } void arbre(int ind, EtatCivil EC){ cout << EC.tableP[ind].nom << endl; cout << " "; if (EC.tableP[ind].indParent1 == -1){ cout << "Individu Incounnu" << endl; }else{ arbre(EC.tableP[ind].indParent1, EC); } cout << " "; if (EC.tableP[ind].indParent2 == -1){ cout << "Individu Incounnu" << endl; }else{ arbre(EC.tableP[ind].indParent2, EC); } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); AfficheEtatCivil(EC); arbre(9, EC); } ```` Alexis: ```cpp void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ int ind; bool ajoutOK = true; if (EC.nbP == MAXPERSONNES) { ajoutOK = false; cout << "La base est pleine, on ne peut pas ajouter une personne." << endl; } else { for (int i = 0; i < EC.nbP; i++) // interdire l'homonymie if (EC.tableP[i].nom == sonNom) { ajoutOK = false; cout << "La personne " << sonNom << " existe deja dans la base." << endl; break; } if (ajoutOK == true) { ind = EC.nbP; EC.tableP[ind].nom = sonNom; EC.tableP[ind].genre = s; EC.tableP[ind].indConjoint = -1; // pas de conjoint EC.tableP[ind].indParent1 = parent1; EC.tableP[ind].indParent2 = parent2; EC.nbP++; // mise a jour du nombre de personnes } } } void AffichePersonne(int ind, EtatCivil EC){ if(ind < EC.nbP){ cout << "Nom : " << EC.tableP[ind].nom << endl; if (EC.tableP[ind].genre == M){ cout << "Genre : Masculin" << endl; } else{ cout << "Genre : Féminin" << endl; } if (EC.tableP[ind].indConjoint > -1){ cout << "Conjoint : " << EC.tableP[EC.tableP[ind].indConjoint].nom << endl; } else{ cout << "Conjoint : inconnu" << endl; } if (EC.tableP[ind].indParent1 > -1){ cout << "Parent 1 : " << EC.tableP[EC.tableP[ind].indParent1].nom << endl; } else{ cout << "Parent 1 : inconnu" << endl; } if (EC.tableP[ind].indParent2 > -1){ cout << "Parent 2 : " << EC.tableP[EC.tableP[ind].indParent2].nom << endl; } else{ cout << "Parent 2 : inconnu" << endl; } } else{ cout << "Cette personne n'est pas dans l'état civil" << endl; } } void AfficheEtatCivil(EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ cout << "Personne n°" << i+1 << " :" << endl; AffichePersonne(i, EC); cout << endl; } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int TrouvePersonne(string nom, EtatCivil EC){ for(int i = 0; i < EC.nbP; i++){ if (nom == EC.tableP[i].nom){ return i; } } return -1; } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); cout << "Test : AffichePersonne" << endl; AffichePersonne(3, EC); cout << endl; cout << "Test : AfficheEtatCivil" << endl; AfficheEtatCivil(EC); } ``` Anne-laure: ```cpp void AjoutPersonne (string n, Genre g,int P1,int P2, EtatCivil &EC){ bool pasErreur=true; if (EC.nbP==MAXPERSONNES){ pasErreur=false; cout<<"il y a deja 50 personnes"<<endl; } for (int i=0; i<EC.nbP; i++){ if (EC.tableP[i].nom==n){ pasErreur=false; cout<<"quelqu'un porte deja ce nom"<<endl; } } if (pasErreur){ Personne p; p.nom= n; p.genre= g; p.indParent1= P1; p.indParent2= P2; p.indConjoint=-1; EC.tableP[EC.nbP]=p; EC.nbP++; } } void AffichePersonne (int indice, EtatCivil EC){ if (indice> EC.nbP){ cout<<"cette personne n'est pas dans l'etat civil"<<endl; } else{ cout<<"nom: "<<EC.tableP[indice].nom<<endl; if (EC.tableP[indice].genre == M){ cout << "genre: M"<<endl; } else{ cout << "genre: F"<<endl; } cout << "indice du conjoint : " << EC.tableP[indice].indConjoint << endl; cout << "indice du parent 1 : " << EC.tableP[indice].indParent1 << endl; cout << "indice du parent 2 : " << EC.tableP[indice].indParent2 << endl; } } void afficheEtatCivil (EtatCivil EC){ for(int i=0; i<EC.nbP;i++){ AffichePersonne (i,EC); cout<<endl; cout<<endl; } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int main(){ EtatCivil EC; EC.nbP=0; RemplitEtatCivil(EC); cout<<"affiche personne 5"<<endl; AffichePersonne(5,EC); cout<<"affiche Etat civil"<<endl; afficheEtatCivil(EC); } int CherchePersonne (string nom, EtatCivil EC){ for (int i=0;i<EC.nbP;i++){ if(EC.tableP[i].nom== nom){ return i; } } return -1; } ASSERT(CherchePersonne("Stephane",EC)==6); ASSERT(CherchePersonne("Noemie",EC)==0); ASSERT(CherchePersonne("Anne",EC)==-1); bool Mariage (string p1,string p2, EtatCivil &EC){ int a = CherchePersonne (p1,EC); int b= CherchePersonne(p2,EC); if (a==-1 or b==-1){ return false; } if (EC.tableP[a].indConjoint==-1 and EC.tableP[b].indConjoint==-1){ EC.tableP[a].indConjoint=b; EC.tableP[b].indConjoint=a; return true; } return false; } void ArbreGénéalogique (int indice, EtatCivil EC,int tab){ string espace = " "; for (int i = 0; i < tab; i++){ espace += " "; } if (indice == -1){ cout <<espace<< "Individu inconnu" << endl; } else { cout <<espace<< EC.tableP[indice].nom << endl; int p1 = EC.tableP[indice].indParent1; int p2 = EC.tableP[indice].indParent2; ArbreGénéalogique(p1, EC, tab+1); ArbreGénéalogique(p2, EC, tab+1); } } ``` Araine: void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ bool aP = true; if(EC.nbP==MAXPERSONNES){ aP=false; cout<<"Le nombre maximum de personnes à été atteint"<<endl; }else{ for(int i=0; i<EC.nbP;i++) if(EC.tableP[i].nom==sonNom){ aP=false; cout<<"Quelqu'un porte déjà ce nom"<<endl; } } if(aP==true){ EC.tableP[EC.nbP].nom=sonNom; EC.tableP[EC.nbP].genre=s; EC.tableP[EC.nbP].indConjoint=-1; EC.tableP[EC.nbP].indParent1=parent1; EC.tableP[EC.nbP].indParent2=parent2; EC.nbP++; cout<<"Personne rajoutée"<<endl; }else{ cout<<"Ajout impossible"<<endl; } } void AffichePersonne(int ind, EtatCivil EC){ for(int i=0; i<EC.nbP; i++){ if(EC.tableP[ind].nom==EC.tableP[i].nom and EC.tableP[ind].genre==EC.tableP[i].genre and EC.tableP[ind].indConjoint==EC.tableP[i].indConjoint and EC.tableP[ind].indParent1==EC.tableP[i].indParent1 and EC.tableP[ind].indParent2==EC.tableP[i].indParent2){ cout<<EC.tableP[ind].nom<<endl; cout<<EC.tableP[ind].genre<<endl; cout<<EC.tableP[ind].indConjoint<<endl; cout<<EC.tableP[ind].indParent1<<endl; cout<<EC.tableP[ind].indParent2<<endl; } } } void AfficheEtatCivil(EtatCivil EC){ for(int i=0; i<EC.nbP; i++){ AffichePersonne(i, EC); } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); Ajovoid RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); AfficheEtatCivil(EC); return 0; } ```cpp Romain : ```cpp #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC); void AffichePersonne(int ind, EtatCivil EC); void AfficheEtatCivil(EtatCivil EC); void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } void AjoutPersonne(string nom, Genre s, int parent1, int parent2, EtatCivil &EC) { bool b = true; if (EC.nbP == MAXPERSONNES) { b = false; cout << "L'etat civil est plein." << endl; } else { for (int i = 0; i < EC.nbP; i++) if (EC.tableP[i].nom == nom) { b = false; cout << "La personne " << nom << " existe deja." << endl; return; } if (b == true) { EC.tableP[EC.nbP].nom = nom; EC.tableP[EC.nbP].genre = s; EC.tableP[EC.nbP].indConjoint = -1; EC.tableP[EC.nbP].indParent1 = parent1; EC.tableP[EC.nbP].indParent2 = parent2; EC.nbP++; } } } void AffichePersonne(int i, EtatCivil EC) { if (i >= EC.nbP) { cout << "La personne d’indice " << i << " n’existe pas." << endl; } else { cout << "Individu " << i << endl; cout << "Nom : " << EC.tableP[i].nom << endl; cout << "Genre : "; if (EC.tableP[i].genre == M)cout << "Masculin" << endl; else cout << "Feminin" << endl; if (EC.tableP[i].indConjoint == -1) cout << "Célibataire" << endl; else cout << "Conjoint: " << EC.tableP[i].indConjoint << endl; cout << "Parents : " << EC.tableP[i].indParent1 << ", " << EC.tableP[i].indParent2 << endl << endl; } } void AfficheEtatCivil(EtatCivil EC) { int i; for(i=0; i<EC.nbP; i++) AffichePersonne(i, EC); } int RecherchePersonne(string nom, EtatCivil EC) { for (int i = 0; i < EC.nbP; i++) if (EC.tableP[i].nom == nom) return i; return -1; } void AfficheArbreGenePersonneAux(int individu, EtatCivil EC, int generation) { cout << "Individu "; if (individu == -1) cout << "inconnu" << endl; else { cout << individu << endl; for (int i=0; i < generation; i++) cout << " "; AfficheArbreGenePersonneAux(EC.tableP[individu].indParent1, EC, generation+1); for (int i=0; i < generation; i++) cout << " "; AfficheArbreGenePersonneAux(EC.tableP[individu].indParent2, EC, generation+1); } } void AfficheArbreGenePersonne(int individu, EtatCivil EC) { int generation = 1; if (individu >= EC.nbP)cout << "La personne d’indice " << individu << " n’existe pas." << endl; else AfficheArbreGenePersonneAux(individu, EC, generation); } bool Mariage(string nom1, string nom2, EtatCivil &EC) { int i1, i2; i1 = RecherchePersonne(nom1, EC); i2 = RecherchePersonne(nom2, EC); if (i1 == -1 || i2 == -1 || EC.tableP[i1].indConjoint != -1 || EC.tableP[i2].indConjoint != -1)return false; EC.tableP[i1].indConjoint = i2; EC.tableP[i2].indConjoint = i1; return true; } int main() { EtatCivil EC; EC.nbP = 0; RemplitEtatCivil(EC); AjoutPersonne("Dark Vador", M, -1, -1, EC); AjoutPersonne("Padme", F, -1, -1, EC); AffichePersonne(0, EC); AffichePersonne(1, EC); AffichePersonne(2, EC); AfficheEtatCivil(EC); cout << "Personne Dark Vador: " << RecherchePersonne("Dark Vador", EC) << endl; cout << "Personne Yoda: " << RecherchePersonne("Yoda", EC) << endl; bool mariage = Mariage("Dark Vador", "Padme", EC); cout << "Mariage Dark Vador et Padme : "; if (mariage)cout << "possible" << endl; else cout << "impossible"; AfficheArbreGenePersonne(9, EC); return 0; } ``` Doriane: ```cpp const int MAXPERSONNES = 50; enum Genre { M, F }; struct Personne{ string nom; Genre genre; int indConjoint, indParent1, indParent2; }; struct EtatCivil { Personne tableP[MAXPERSONNES]; int nbP; }; void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC); void AffichePersonne(int ind, EtatCivil EC); void AfficheEtatCivil(EtatCivil EC); void AjoutPersonne(string sonNom, Genre s, int parent1, int parent2, EtatCivil &EC){ int indice; bool ajout=true; if (EC.nbP==MAXPERSONNES){ ajout=false; cout<<"déso, on rajoute personne, la base est pleine"<<endl; } else{ for(int i = 0; i<EC.nbP; i++){ if (EC.tableP[i].nom==sonNom){ ajout=false; cout<<"déso, ce nom est déja pris, on le rajoute pas à la base"<<endl; } } } if(ajout==true) { indice=EC.nbP; EC.tableP[indice].nom = sonNom; EC.tableP[indice].genre = s; EC.tableP[indice].indConjoint=-1; EC.tableP[indice].indParent1 = parent1; EC.tableP[indice].indParent2 = parent2; EC.nbP++; } } void AffichePersonne(int ind, EtatCivil EC){ if(EC.nbP<ind+1){ cout<<"déso, cette personne n'existe pas"<<endl; } else{ cout<<"Son nom est "<<EC.tableP[ind].nom<<endl; if(EC.tableP[ind].genre==M){ cout<<"Genre : Masculin"<<endl; } else{ cout<<"Genre : Féminin"<<endl; } if (0<=EC.tableP[ind].indConjoint<=EC.nbP){ cout<<"Son conjoint s'appelle "<<EC.tableP[EC.tableP[ind].indConjoint].nom<<endl; } else{ cout<<"Cette personne n'est pas mariée"<<endl; } if (0<=EC.tableP[ind].indParent1<=EC.nbP){ cout<<"Un de ses parent s'appelle "<<EC.tableP[EC.tableP[ind].indParent1].nom<<endl; } if(0<=EC.tableP[ind].indParent2<=EC.nbP){ cout<<"Un de ses parent s'appelle "<<EC.tableP[EC.tableP[ind].indParent2].nom<<endl; } } } void AfficheEtatCivil(EtatCivil EC){ for(int i = 0; i<EC.nbP;i++){ cout<<EC.tableP[i].nom<<endl; cout<<endl; } } void RemplitEtatCivil(EtatCivil &EC) { // remplit l'état civil avec 20 personnes AjoutPersonne("Noemie", F, -1, -1, EC); AjoutPersonne("Georges", M, -1, -1, EC); AjoutPersonne("Albert", M, -1, -1, EC); AjoutPersonne("Marie", F, -1, -1, EC); AjoutPersonne("Luc", M, 0, -1, EC); AjoutPersonne("Valerie", F, -1, 1, EC); AjoutPersonne("Stephane", M, 3, 2, EC); AjoutPersonne("Helene", F, 5, 4, EC); AjoutPersonne("Justine", F, 7, 6, EC); AjoutPersonne("Berenice", F, 5, 10, EC); AjoutPersonne("John", M, 12, 11, EC); AjoutPersonne("Franco", M, -1, -1, EC); AjoutPersonne("Viviane", F, -1, -1, EC); AjoutPersonne("Pierre", M, 9, 14, EC); AjoutPersonne("Remi", M, 16, 15, EC); AjoutPersonne("Boris", M, -1, 17, EC); AjoutPersonne("Sharon", F, 19, 18, EC); AjoutPersonne("Alexandre", M, -1, -1, EC); AjoutPersonne("Augustin", M, -1, -1, EC); AjoutPersonne("Johanne", F, -1, -1, EC); } int Cherche(string sonNom, EtatCivil EC){ for(int i=0; i<MAXPERSONNES;i++){ if (sonNom==EC.tableP[i].nom){ return i; } } return -1; } bool mariage(string nom1, string nom2, EtatCivil EC){ int ind1; int ind2; ind1=Cherche(nom1, EC); ind2=Cherche(nom2, EC); if(ind1==-1 or ind2==-1){ return false; } else{ if(0<=EC.tableP[ind1].indConjoint<=EC.nbP or 0<=EC.tableP[ind2].indConjoint<=EC.nbP){ return false; } EC.tableP[ind1].indConjoint=ind2; EC.tableP[ind2].indConjoint=ind1; return true; } } void arbre(int indice, EtatCivil EC){ cout<<"individu "; if (indice<0 or indice>EC.nbP) { cout<<"inconnu"<<endl; } else { cout<<indice<<endl; //si la personne existe, on met son indice cout<<" individu "; if(EC.tableP[indice].indParent1<0 or EC.tableP[indice].indParent1>EC.nbP){ cout<<"inconnu"<<endl; //dans le cas ou on ne connais pas sa mere. } else{ //on regarde si elle a une mere cout<<EC.tableP[indice].indParent1<<endl; cout<<" "; cout<<" individu"; if(EC.tableP[EC.tableP[indice].indParent1].indParent1!=-1){ //on regarde si elle a une grand mere du coté de la mere cout<<" "<<EC.tableP[EC.tableP[indice].indParent1].indParent1<<endl; } else{ cout<<" inconnu"<<endl; } cout<<" "; cout<<" individu"; if (EC.tableP[EC.tableP[indice].indParent1].indParent2==-1){ cout<<" inconnu"<<endl; } else{ //on regarde si elle a un grand pere du cote de la mere cout<<" "<<EC.tableP[EC.tableP[indice].indParent1].indParent2<<endl; } } if(EC.tableP[indice].indParent2!=-1){ //on regarde si elle a un pere cout<<" "; cout<<"individu "<<EC.tableP[indice].indParent2<<endl; cout<<" "; cout<<" individu"; if(EC.tableP[EC.tableP[indice].indParent2].indParent1!=-1){ //on regarde si elle a une grand mere du coté du pere cout<<" "<<EC.tableP[EC.tableP[indice].indParent2].indParent1<<endl; } else{ cout<<" inconnu"<<endl; } cout<<" "; cout<<" individu"; if(EC.tableP[EC.tableP[indice].indParent2].indParent2!=-1){ //on regarde si elle a un grand pere du cote du pere cout<<" "<<EC.tableP[EC.tableP[indice].indParent2].indParent2<<endl; } else{ cout<<" inconnu"<<endl; } } else{ cout<<" "; cout<<"individu"; cout<<" inconnu"<<endl; //dans le cas ou on ne connais pas son pere. } } } int main() { EtatCivil EC; EC.nbP = 0; // il est necessaire d'initialiser le nombre de personnes RemplitEtatCivil(EC); AfficheEtatCivil(EC); int pnj; cout<<"indice?"<<endl; cin>>pnj; arbre(pnj, EC); return 0; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully