TP8: LocalProfEtud

This commit is contained in:
2024-11-29 10:28:40 +01:00
parent 0a54ea3aca
commit 3aede38c75
6 changed files with 416 additions and 0 deletions

Binary file not shown.

View File

@@ -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

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{83b564f0-1e99-46b8-bb4a-c56173748ca2}</ProjectGuid>
<RootNamespace>LocalProfEtud</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Fichiers sources">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Fichiers d%27en-tête">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Fichiers de ressources">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

224
TP8/LocalProfEtud/main.cpp Normal file
View File

@@ -0,0 +1,224 @@
#include <iostream>
#include <vector>
#include <list>
#include <string>
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<int> mat;
public:
void saisie();
void affiche();
string getnom() { return nom; }
void personnes(list<Personne> etuds, vector<Personne> profs);
template <class T>
bool affiche_local(T t, int m);
};
template <class C, class T>
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 <class T>
void affiche_el(T t) {
t.affiche();
}
void affiche_el(string t) {
cout << t;
}
template <class C>
void affiche(C cont) {
for (auto v : cont) {
affiche_el(v);
cout << endl;
}
cout << endl;
}
template <class C>
void copie_nom(list<string>& cont, C c) {
for (auto a : c) {
cont.push_back(a.getnom());
}
}
void tri_doublon(list<string>& c) {
c.sort();
c.unique();
}
void local_prof_etud(list<Local> locaux, list<Personne> etuds, vector<Personne> profs) {
for (auto local : locaux) {
local.personnes(etuds, profs);
}
}
int menu() {
int c;
cout << "1) Saisie d1 Vector de Prof (insertion à la Fin) + Affichage" << endl
<< "2) Saisie d1 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<Personne> profs;
list<Personne> etuds;
list<string> list2;
list<Local> locaux;
setlocale(LC_ALL, "");
while (true) {
switch (menu()) {
case 1:
saisie<vector<Personne>, Personne>(profs, "Prof");
affiche(profs);
break;
case 2:
saisie<list<Personne>, 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<list<Local>, 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"<<i<<" ? : ";
cin >> a; cin.ignore();
mat.insert(mat.begin(), a);
}
}
void Local::affiche() {
cout << "Nom : " << nom << endl;
int i = 0;
for (auto m : mat) {
cout << "Mat"<<i<<" : " << m << endl;
i++;
}
}
void Local::personnes(list<Personne> etuds, vector<Personne> 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 <class T>
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;
}