diff --git a/TP8/LocalProfEtud/Coté_Local_ ProfEtud_VF.pdf b/TP8/LocalProfEtud/Coté_Local_ ProfEtud_VF.pdf new file mode 100644 index 0000000..91f10dc Binary files /dev/null and b/TP8/LocalProfEtud/Coté_Local_ ProfEtud_VF.pdf differ diff --git a/TP8/LocalProfEtud/LocalProfEtud.sln b/TP8/LocalProfEtud/LocalProfEtud.sln new file mode 100644 index 0000000..f228329 --- /dev/null +++ b/TP8/LocalProfEtud/LocalProfEtud.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}") = "LocalProfEtud", "LocalProfEtud.vcxproj", "{83B564F0-1E99-46B8-BB4A-C56173748CA2}" +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 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Debug|x64.ActiveCfg = Debug|x64 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Debug|x64.Build.0 = Debug|x64 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Debug|x86.ActiveCfg = Debug|Win32 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Debug|x86.Build.0 = Debug|Win32 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Release|x64.ActiveCfg = Release|x64 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Release|x64.Build.0 = Release|x64 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Release|x86.ActiveCfg = Release|Win32 + {83B564F0-1E99-46B8-BB4A-C56173748CA2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0D26026B-8543-4D1F-8BC1-774CD02E70A1} + EndGlobalSection +EndGlobal diff --git a/TP8/LocalProfEtud/LocalProfEtud.vcxproj b/TP8/LocalProfEtud/LocalProfEtud.vcxproj new file mode 100644 index 0000000..d3ca7fe --- /dev/null +++ b/TP8/LocalProfEtud/LocalProfEtud.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {83b564f0-1e99-46b8-bb4a-c56173748ca2} + LocalProfEtud + 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/TP8/LocalProfEtud/LocalProfEtud.vcxproj.filters b/TP8/LocalProfEtud/LocalProfEtud.vcxproj.filters new file mode 100644 index 0000000..5d997ac --- /dev/null +++ b/TP8/LocalProfEtud/LocalProfEtud.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/TP8/LocalProfEtud/LocalProfEtud.vcxproj.user b/TP8/LocalProfEtud/LocalProfEtud.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/TP8/LocalProfEtud/LocalProfEtud.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TP8/LocalProfEtud/main.cpp b/TP8/LocalProfEtud/main.cpp new file mode 100644 index 0000000..2f73aad --- /dev/null +++ b/TP8/LocalProfEtud/main.cpp @@ -0,0 +1,224 @@ +#include +#include +#include +#include + +using namespace std; + +class Personne { + string nom; + int mat1, mat2; + +public: + void saisie(); + void affiche(); + + string getnom() { return nom; } + int getmat1() { return mat1; } + int getmat2() { return mat2; } +}; + +class Local { + string nom; + list mat; +public: + void saisie(); + void affiche(); + + string getnom() { return nom; } + + void personnes(list etuds, vector profs); + + template + bool affiche_local(T t, int m); +}; + +template +void saisie(C& cont, const string name) { + int n; + cout << "Nbr " << name << " : "; + cin >> n; cin.ignore(); + + while (n-- > 0) { + T obj; + + obj.saisie(); + + cont.insert(cont.end(), obj); + //cont.push_back(saisie); + } +} + +template +void affiche_el(T t) { + t.affiche(); +} + +void affiche_el(string t) { + cout << t; +} + +template +void affiche(C cont) { + for (auto v : cont) { + affiche_el(v); + cout << endl; + } + cout << endl; +} + + +template +void copie_nom(list& cont, C c) { + for (auto a : c) { + cont.push_back(a.getnom()); + } +} + +void tri_doublon(list& c) { + c.sort(); + c.unique(); +} + +void local_prof_etud(list locaux, list etuds, vector profs) { + for (auto local : locaux) { + local.personnes(etuds, profs); + } +} + +int menu() { + int c; + + cout << "1) Saisie d’1 Vector de Prof (insertion à la Fin) + Affichage" << endl + << "2) Saisie d’1 List de Etud(insertion à la Fin) + Affichage" << endl + << "3) Copie des noms des Prof et Etud dans List2" << endl + << "4) TRI et Supprime les doublons(noms) de la List2 + Affichage" << endl + << "5) Saisie des \"Local\" + Affichage" << endl + << "6) Pour tout mat_i appartenant au Local Afficher Prof + Etud" << endl; + cout << "Choix : "; + + cin >> c; cin.ignore(); + return c; +} + +int main() { + vector profs; + list etuds; + + list list2; + + list locaux; + + setlocale(LC_ALL, ""); + + while (true) { + switch (menu()) { + case 1: + saisie, Personne>(profs, "Prof"); + affiche(profs); + + break; + case 2: + saisie, Personne>(etuds, "Etud"); + affiche(etuds); + + break; + case 3: + copie_nom(list2, profs); + copie_nom(list2, etuds); + affiche(list2); + + + break; + + case 4: + tri_doublon(list2); + affiche(list2); + + break; + + case 5: + saisie, Local>(locaux, "Locaux"); + affiche(locaux); + + break; + case 6: + local_prof_etud(locaux, etuds, profs); + + break; + default: + return 0; + } + } + + return 0; +} + +void Personne::saisie() { + cout << "Son nom ? : "; + getline(cin, nom); + cout << "Sa mat1 ? : "; + cin >> mat1; cin.ignore(); + cout << "Sa mat2 ? : "; + cin >> mat2; cin.ignore(); +} + +void Personne::affiche() { + cout << "Nom : " << nom << endl; + cout << "Mat1 : " << mat1 << endl; + cout << "Mat2 : " << mat2 << endl; +} + + +void Local::saisie() { + cout << "Son nom ? : "; + getline(cin, nom); + cout << "nbr mat ? :"; + int m; + cin >> m; + for(int i = 0; i< m;i++) { + int a; + cout << "Mat"<> a; cin.ignore(); + mat.insert(mat.begin(), a); + } +} + +void Local::affiche() { + cout << "Nom : " << nom << endl; + int i = 0; + for (auto m : mat) { + cout << "Mat"< etuds, vector profs) { + cout << nom << " " << endl; + for (auto m : mat) { + cout << " " << "Mat" << m << " : "; + + bool f; + + f = affiche_local(etuds, m); + f |= affiche_local(profs, m); + + if (!f) { + cout << "NULL"; + } + + cout << endl; + } +} + +template +bool Local::affiche_local(T t, int m) { + bool f = false; + for (auto e : t) { + if (e.getmat1() == m || e.getmat2() == m) { + cout << e.getnom() << ", "; + f = true; + } + } + return f; +} \ No newline at end of file