diff --git a/TP6/TP6.sln b/TP6/TP6.sln
new file mode 100644
index 0000000..3ca69e3
--- /dev/null
+++ b/TP6/TP6.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34221.43
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TP6", "TP6.vcxproj", "{C1CE1082-4EB0-43D9-8755-76FB40FF79CE}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Debug|x64.ActiveCfg = Debug|x64
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Debug|x64.Build.0 = Debug|x64
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Debug|x86.ActiveCfg = Debug|Win32
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Debug|x86.Build.0 = Debug|Win32
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Release|x64.ActiveCfg = Release|x64
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Release|x64.Build.0 = Release|x64
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Release|x86.ActiveCfg = Release|Win32
+ {C1CE1082-4EB0-43D9-8755-76FB40FF79CE}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1F44335C-36DF-43F4-8EA1-044BA57E5AB7}
+ EndGlobalSection
+EndGlobal
diff --git a/TP6/TP6.vcxproj b/TP6/TP6.vcxproj
new file mode 100644
index 0000000..c84eb04
--- /dev/null
+++ b/TP6/TP6.vcxproj
@@ -0,0 +1,135 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 17.0
+ Win32Proj
+ {c1ce1082-4eb0-43d9-8755-76fb40ff79ce}
+ TP6
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TP6/TP6.vcxproj.filters b/TP6/TP6.vcxproj.filters
new file mode 100644
index 0000000..5d997ac
--- /dev/null
+++ b/TP6/TP6.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Fichiers sources
+
+
+
\ No newline at end of file
diff --git a/TP6/TP6.vcxproj.user b/TP6/TP6.vcxproj.user
new file mode 100644
index 0000000..88a5509
--- /dev/null
+++ b/TP6/TP6.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/TP6/main.cpp b/TP6/main.cpp
new file mode 100644
index 0000000..12a5e38
--- /dev/null
+++ b/TP6/main.cpp
@@ -0,0 +1,279 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class Personne {
+ int Id;
+ string Nom;
+
+public:
+ using SAISIE = int;
+
+ Personne() {
+ static int i = 0;
+
+ Id = ++i;
+ }
+
+ Personne(int Id) : Id(Id) {};
+
+ void saisie() { getline(cin, Nom, ' '); }
+ void afficher() { cout << left << setw(3) << Id << left << setw(8) << Nom; }
+
+ // paramètre saisie n'est pas utilisé par défaut
+ static SAISIE parametre_saisie() { return 0; }
+ static string nomclasse() { return "personne"; }
+
+ bool operator==(string nom) { return Nom == nom; }
+
+ bool operator<(Personne& b) const noexcept { return Nom < b.Nom; }
+};
+
+
+
+class Prof : public Personne {
+ string service;
+
+
+public:
+ static int i;
+ using SAISIE = char;
+
+ Prof() : Personne(++i) {};
+
+ void saisie(SAISIE n) { Personne::saisie(); getline(cin, service, n); }
+ void afficher() { Personne::afficher(); cout << left << setw(8) << service; }
+
+ static string nomclasse() { return "prof"; }
+ static SAISIE parametre_saisie() {return '\n';}
+};
+
+class Direction : public Prof {
+ string Titre;
+
+public:
+
+
+ void saisie() { Prof::saisie(' '); getline(cin, Titre); }
+ void afficher() { Prof::afficher(); cout << left << setw(8) << Titre; }
+
+ static string nomclasse() { return "direction"; };
+
+ template
+ void moyennes(C& etudiants) {
+ cout << "==Moyennes==" << endl;
+ for (auto etud : etudiants) {
+ cout << endl;
+ etud.afficher();
+
+ etud.Moy = 0;
+ for (int i = 0; i < etud.N_Note; i++) {
+ etud.Moy += etud.Note[i];
+ }
+ etud.Moy = (float)etud.Moy / (float)etud.N_Note;
+ cout << "M: " << setprecision(4) << etud.Moy;
+ }
+ cout << endl;
+ };
+};
+
+class Etudiant : public Personne {
+ string An_Scol;
+ int Note[3];
+ int N_Note;
+ float Moy;
+
+ friend class Direction;
+ friend bool tri_etud(const Etudiant& a, const Etudiant& b);
+
+public:
+ static int i;
+
+ using SAISIE = int;
+
+ Etudiant() : Personne(++i) {};
+
+ void saisie(int n) {
+ Personne::saisie();
+
+ getline(cin, An_Scol, ' ');
+
+ string tmp;
+ N_Note = n;
+
+ for (int i = 0; i < N_Note-1; i++) {
+ getline(cin, tmp, ' ');
+ Note[i] = stoi(tmp);
+ }
+ cin >> Note[N_Note-1];
+ cin.ignore();
+ }
+
+ void afficher() { Personne::afficher(); cout << left << setw(6) << An_Scol; for (int i = 0; i < N_Note; i++) cout << left << setw(4) << Note[i]; }
+
+ // Retourne le nom de la classe pour la saisie
+ static string nomclasse() { return "étudiant"; }
+
+ static SAISIE parametre_saisie() {
+ int mat = 0;
+ do {
+ cout << "Nombre de matière (<= 3) : ";
+ cin >> mat; cin.ignore();
+ } while (mat <= 0 || mat > 3);
+
+ return mat;
+ }
+};
+
+int Prof::i = 0;
+int Etudiant::i = 0;
+
+
+template
+void saisie(C& conteneur) {
+ // récupération du type stocké dans le conteneur, évite de devoir
+ // passer un 2e variable en paramètre
+ using A = typename C::value_type;
+
+ // Le type "SAISIE" stocké sur la classe,
+ // permet de saisir virtuellement n'importe en quoi avant la saisie de chaque élémement
+ // 1x avant les itérations
+ using SAISIE = typename A::SAISIE;
+
+ int n;
+
+ cout << "Nombre de " << A::nomclasse() << " : ";
+ cin >> n; cin.ignore();
+
+ SAISIE p = A::parametre_saisie();
+
+ while (n-- > 0) {
+ // A a;
+ // a.saisie();
+ // conteneur.insert(conteneur.end(), a);
+
+ conteneur.emplace(conteneur.end())->saisie(p);
+ }
+ cout << endl;
+}
+
+template
+void afficher(C& conteneur) {
+ using V = typename C::value_type;
+
+ cout << "Affichage de " << V::nomclasse() << endl;
+
+ for (auto &v : conteneur) {
+ cout << endl; v.afficher();
+ }
+ cout << endl;
+}
+
+template
+bool recherche(C& conteneur, string recherche) {
+ using T = typename C::value_type;
+
+ auto et = find(conteneur.begin(), conteneur.end(), recherche);
+
+ if (et != conteneur.end()) {
+ cout << recherche << " existe. Il s'agit d'un " << T::nomclasse();
+ return true;
+ }
+
+ return false;
+}
+
+// a < b
+bool tri_etud(const Etudiant& a, const Etudiant& b) {
+ if (a.An_Scol.length() != 3 || b.An_Scol.length() != 3) {
+ return a.Moy < b.Moy;
+ }
+
+ if (a.An_Scol[0] != b.An_Scol[0]) {
+ return a.An_Scol[0] < b.An_Scol[0];
+ }
+ else if (a.An_Scol[2] != b.An_Scol[2]) {
+ return a.An_Scol[2] < b.An_Scol[2];
+ }
+ else {
+ return a.Moy < b.Moy;
+ }
+}
+
+
+int menu() {
+ int c;
+ cout << endl;
+ cout<< " 1. Saisir N Etudiants et afficher" << endl
+ << " 2. Saisir M Profs et affichage" << endl
+ << " 3. Doyen membre de Direction Calcule la moyenne de chaque étudiant et affichage" << endl
+ << " 4. Chercher selon le NOM si un Etud ou Prof existe et affichage" << endl
+ << " 5. Trier selon le Nom(Etud ou Prof) par ordre croissant et affichage" << endl
+ << " 6. Afficher la liste des étudiants par année scolaire et par ordre décroissant de leur moyenne" << endl
+ << " 7. Quitter" << endl;
+ cout << "Choix :";
+ cin >> c; cin.ignore();
+
+ return c;
+}
+
+int main() {
+ int c;
+ string r;
+
+ list etudiants;
+ vector profs;
+ Direction doyen;
+
+ setlocale(LC_ALL, "");
+
+
+ while ((c = menu()) != 7) {
+ switch (c) {
+ case 1:
+ saisie(etudiants);
+ afficher(etudiants);
+
+ break;
+ case 2:
+ saisie(profs);
+ afficher(profs);
+
+ break;
+ case 3:
+ doyen.saisie();
+ cout << "Affichage doyen" << endl; doyen.afficher(); cout << endl;
+ doyen.moyennes(etudiants);
+
+ break;
+
+ case 4:
+ cout << "Entrer un Nom : " << endl;
+ getline(cin, r);
+
+ recherche(etudiants, r) || recherche(profs, r) || (cout << r << " n'existe pas !! ");
+ break;
+
+ case 5:
+ etudiants.sort();
+ afficher(etudiants);
+
+ sort(profs.begin(), profs.end());
+ afficher(profs);
+
+
+ break;
+ case 6:
+ etudiants.sort(tri_etud);
+ afficher(etudiants);
+ break;
+ }
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/TP6/main.cpp.txt b/TP6/main.cpp.txt
new file mode 100644
index 0000000..7ac93e1
--- /dev/null
+++ b/TP6/main.cpp.txt
@@ -0,0 +1,277 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class Personne {
+ int Id;
+ string Nom;
+
+public:
+ using SAISIE = int;
+
+ Personne() {
+ static int i = 0;
+ Id = ++i;
+ }
+
+ Personne(int Id) : Id(Id) {};
+
+ void saisie() { getline(cin, Nom, ' '); }
+ void afficher() { cout << left << setw(3) << Id << left << setw(8) << Nom; }
+
+ // paramètre saisie n'est pas utilisé par défaut
+ static SAISIE parametre_saisie() { return 0; }
+ static string nomclasse() { return "personne"; }
+
+ bool operator==(string nom) { return Nom == nom; }
+
+ bool operator<(Personne& b) const noexcept { return Nom < b.Nom; }
+};
+
+
+
+class Prof : public Personne {
+ string service;
+
+
+public:
+ static int i;
+ using SAISIE = char;
+
+ //Prof() : Personne(++i) {};
+
+ void saisie(SAISIE n) { Personne::saisie(); getline(cin, service, n); }
+ void afficher() { Personne::afficher(); cout << left << setw(8) << service; }
+
+ static string nomclasse() { return "prof"; }
+ static SAISIE parametre_saisie() {return '\n';}
+};
+
+class Direction : public Prof {
+ string Titre;
+
+public:
+ void saisie() { Prof::saisie(' '); getline(cin, Titre); }
+ void afficher() { Prof::afficher(); cout << left << setw(8) << Titre; }
+
+ static string nomclasse() { return "direction"; };
+
+ template
+ void moyennes(C& etudiants) {
+ cout << "==Moyennes==" << endl;
+ for (auto etud : etudiants) {
+ cout << endl;
+ etud.afficher();
+
+ etud.Moy = 0;
+ for (int i = 0; i < etud.N_Note; i++) {
+ etud.Moy += etud.Note[i];
+ }
+ etud.Moy = (float)etud.Moy / (float)etud.N_Note;
+ cout << "M: " << setprecision(4) << etud.Moy;
+ }
+ cout << endl;
+ };
+};
+
+class Etudiant : public Personne {
+ string An_Scol;
+ int Note[3];
+ int N_Note;
+ float Moy;
+
+ friend class Direction;
+ friend bool tri_etud(const Etudiant& a, const Etudiant& b);
+
+public:
+ static int i;
+
+ using SAISIE = int;
+
+
+ //Etudiant() : Personne(++i) {};
+
+ void saisie(int n) {
+ Personne::saisie();
+
+ getline(cin, An_Scol, ' ');
+
+ string tmp;
+ N_Note = n;
+
+ for (int i = 0; i < N_Note-1; i++) {
+ getline(cin, tmp, ' ');
+ Note[i] = stoi(tmp);
+ }
+ cin >> Note[N_Note-1];
+ cin.ignore();
+ }
+
+ void afficher() { Personne::afficher(); cout << left << setw(6) << An_Scol; for (int i = 0; i < N_Note; i++) cout << left << setw(4) << Note[i]; }
+
+ // Retourne le nom de la classe pour la saisie
+ static string nomclasse() { return "étudiant"; }
+
+ static SAISIE parametre_saisie() {
+ int mat = 0;
+ do {
+ cout << "Nombre de matière (<= 3) : ";
+ cin >> mat; cin.ignore();
+ } while (mat <= 0 || mat > 3);
+
+ return mat;
+ }
+};
+
+int Prof::i = 0;
+int Etudiant::i = 0;
+
+
+template
+void saisie(C& conteneur) {
+ // récupération du type stocké dans le conteneur, évite de devoir
+ // passer un 2e variable en paramètre
+ using A = typename C::value_type;
+
+ // Le type "SAISIE" stocké sur la classe,
+ // permet de saisir virtuellement n'importe en quoi avant la saisie de chaque élémement
+ // 1x avant les itérations
+ using SAISIE = typename A::SAISIE;
+
+ int n;
+
+ cout << "Nombre de " << A::nomclasse() << " : ";
+ cin >> n; cin.ignore();
+
+ SAISIE p = A::parametre_saisie();
+
+ while (n-- > 0) {
+ // A a;
+ // a.saisie();
+ // conteneur.insert(conteneur.end(), a);
+
+ conteneur.emplace(conteneur.end())->saisie(p);
+ }
+ cout << endl;
+}
+
+template
+void afficher(C& conteneur) {
+ using V = typename C::value_type;
+
+ cout << "Affichage de " << V::nomclasse() << endl;
+
+ for (auto &v : conteneur) {
+ cout << endl; v.afficher();
+ }
+ cout << endl;
+}
+
+template
+bool recherche(C& conteneur, string recherche) {
+ using T = typename C::value_type;
+
+ auto et = find(conteneur.begin(), conteneur.end(), recherche);
+
+ if (et != conteneur.end()) {
+ cout << recherche << " existe. Il s'agit d'un " << T::nomclasse();
+ return true;
+ }
+
+ return false;
+}
+
+// a < b
+bool tri_etud(const Etudiant& a, const Etudiant& b) {
+ if (a.An_Scol.length() != 3 || b.An_Scol.length() != 3) {
+ return a.Moy < b.Moy;
+ }
+
+ if (a.An_Scol[0] != b.An_Scol[0]) {
+ return a.An_Scol[0] < b.An_Scol[0];
+ }
+ else if (a.An_Scol[2] != b.An_Scol[2]) {
+ return a.An_Scol[2] < b.An_Scol[2];
+ }
+ else {
+ return a.Moy < b.Moy;
+ }
+}
+
+
+int menu() {
+ int c;
+ cout << endl;
+ cout<< " 1. Saisir N Etudiants et afficher" << endl
+ << " 2. Saisir M Profs et affichage" << endl
+ << " 3. Doyen membre de Direction Calcule la moyenne de chaque étudiant et affichage" << endl
+ << " 4. Chercher selon le NOM si un Etud ou Prof existe et affichage" << endl
+ << " 5. Trier selon le Nom(Etud ou Prof) par ordre croissant et affichage" << endl
+ << " 6. Afficher la liste des étudiants par année scolaire et par ordre décroissant de leur moyenne" << endl
+ << " 7. Quitter" << endl;
+ cout << "Choix :";
+ cin >> c; cin.ignore();
+
+ return c;
+}
+
+int main() {
+ int c;
+ string r;
+
+ list etudiants;
+ vector profs;
+ Direction doyen;
+
+ setlocale(LC_ALL, "");
+
+
+ while ((c = menu()) != 7) {
+ switch (c) {
+ case 1:
+ saisie(etudiants);
+ afficher(etudiants);
+
+ break;
+ case 2:
+ saisie(profs);
+ afficher(profs);
+
+ break;
+ case 3:
+ doyen.saisie();
+ cout << "Affichage doyen" << endl; doyen.afficher(); cout << endl;
+ doyen.moyennes(etudiants);
+
+ break;
+
+ case 4:
+ cout << "Entrer un Nom : " << endl;
+ getline(cin, r);
+
+ recherche(etudiants, r) || recherche(profs, r) || (cout << r << " n'existe pas !! ");
+ break;
+
+ case 5:
+ etudiants.sort();
+ afficher(etudiants);
+
+ sort(profs.begin(), profs.end());
+ afficher(profs);
+
+
+ break;
+ case 6:
+ etudiants.sort(tri_etud);
+ afficher(etudiants);
+ break;
+ }
+ }
+
+ return 0;
+}
\ No newline at end of file