Compare commits
18 Commits
98c6f8210b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 53268166a3 | |||
| ca9cb36223 | |||
| 3f473e5f99 | |||
| 3aede38c75 | |||
| 0a54ea3aca | |||
| 456150e6b1 | |||
| a465aa9e59 | |||
| bc02b5e336 | |||
| a7adcbfd9f | |||
| cad0849e75 | |||
| b1d4730e60 | |||
| 582bc26ad7 | |||
| add166edcd | |||
| 91323c4465 | |||
| 732be7767f | |||
| 6c5fec1823 | |||
| 094bef3d10 | |||
| cbceba2519 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.vs
|
||||
x64
|
||||
bis
|
||||
|
||||
33
TP1/1.1.cpp
Normal file
33
TP1/1.1.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int nbEnfants = 2;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
if (nbEnfants == 0)
|
||||
{
|
||||
cout << "Eh bien alors, vous n'avez pas d'enfant ?";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nbEnfants == 1)
|
||||
{
|
||||
cout << "Alors c'est pour quand le deuxième ?";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nbEnfants == 2)
|
||||
{
|
||||
cout << "Quels beaux enfants vous avez là !";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Bon, il faut arrêter de faire des gosses maintenant";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
TP1/1.2.cpp
Normal file
110
TP1/1.2.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 10;
|
||||
|
||||
void print_tab(int tab[], int n);
|
||||
|
||||
void print_help(int tab[], int n);
|
||||
|
||||
void insert_begin(int v, int tab[], int &n);
|
||||
|
||||
void insert_end(int v, int tab[], int &n);
|
||||
|
||||
void pop(int i, int tab[], int &n);
|
||||
|
||||
int main()
|
||||
{
|
||||
int tab[Nmax] = {5, 3, 11, 9, 2};
|
||||
int n = 5;
|
||||
int v;
|
||||
|
||||
char c;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (true)
|
||||
{
|
||||
print_help(tab, n);
|
||||
cout << "Votre choix : ";
|
||||
cin >> c;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
if (n >= Nmax)
|
||||
break;
|
||||
cout << "Entrez la valeur à ajouter : ";
|
||||
cin >> v;
|
||||
insert_begin(v, tab, n);
|
||||
|
||||
break;
|
||||
case 'b':
|
||||
if (n >= Nmax)
|
||||
break;
|
||||
cout << "Entrez la valeur à ajouter : ";
|
||||
cin >> v;
|
||||
insert_end(v, tab, n);
|
||||
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (n < 2)
|
||||
break;
|
||||
pop(1, tab, n);
|
||||
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_tab(int tab[], int n)
|
||||
{
|
||||
cout << "[";
|
||||
for (int i = 0; i < n - 1; i++)
|
||||
{
|
||||
cout << tab[i] << ", ";
|
||||
}
|
||||
if (n > 0)
|
||||
cout << tab[n - 1];
|
||||
cout << "]";
|
||||
}
|
||||
|
||||
void print_help(int tab[], int n)
|
||||
{
|
||||
cout << "Tableau ";
|
||||
print_tab(tab, n);
|
||||
cout << endl;
|
||||
cout << "a) Ajouter au début du tableau une valeur introduite par l'utilisateur\n";
|
||||
cout << "b) Ajouter à la fin du tableau une valeur introduite par l'utilisateur\n";
|
||||
cout << "c) Supprimer la valeur de l'élément à la deuxième position du tableau\n";
|
||||
cout << "d) Quitter\n";
|
||||
}
|
||||
|
||||
void insert_begin(int v, int tab[], int &n)
|
||||
{
|
||||
for (int i = n - 1; i >= 0; i--)
|
||||
{
|
||||
tab[i + 1] = tab[i];
|
||||
}
|
||||
tab[0] = v;
|
||||
n++;
|
||||
}
|
||||
|
||||
void insert_end(int v, int tab[], int &n)
|
||||
{
|
||||
tab[n++] = v;
|
||||
}
|
||||
|
||||
void pop(int i, int tab[], int &n)
|
||||
{
|
||||
for (; i < n - 1; i++)
|
||||
{
|
||||
tab[i] = tab[i + 1];
|
||||
}
|
||||
n--;
|
||||
}
|
||||
62
TP1/1.3.cpp
Normal file
62
TP1/1.3.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int EntreeEtudiant(string &mat, int &Ea, int &Eb);
|
||||
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
do
|
||||
{
|
||||
cout << "Entrez le nombre d'étudiants : ";
|
||||
cin >> n;
|
||||
} while (n < 0 || n > 10);
|
||||
|
||||
// tableaux alloués dynamiquements aussi possible statiquement
|
||||
// const int Nmax = 10;
|
||||
// avec string TabMat[Nmax];
|
||||
string *TabMat = new string[n];
|
||||
int *TabEa = new int[n];
|
||||
int *TabEb = new int[n];
|
||||
int Moy;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cout << "--- Etudiant " << i << " ---\n";
|
||||
Moy = EntreeEtudiant(TabMat[i], TabEa[i], TabEb[i]);
|
||||
// cout << "Entrez le matricule de l'étudiant (" << (i + 1) << ") : ";
|
||||
// cin >> TabMat[i];
|
||||
// cout << "Entrez la note Ea (" << (i + 1) << ") : ";
|
||||
// cin >> TabEa[i];
|
||||
// cout << "Entrez la note Eb (" << (i + 1) << ") : ";
|
||||
// cin >> TabEb[i];
|
||||
|
||||
cout << "Somme de Ea et Eb : " << Moy << "\n";
|
||||
cout << "Moyenne de Ea et Eb : " << setprecision(2)
|
||||
<< (Moy / 2) << "\n";
|
||||
}
|
||||
|
||||
// inutile car fin du programme
|
||||
// et la mémoire sera libérée par l'OS
|
||||
delete TabMat;
|
||||
delete TabEa;
|
||||
delete TabEb;
|
||||
}
|
||||
|
||||
int EntreeEtudiant(string &mat, int &Ea, int &Eb)
|
||||
{
|
||||
cout << "Entrez le matricule de l'étudiant : ";
|
||||
cin >> mat;
|
||||
cout << "Entrez la note Ea : ";
|
||||
cin >> Ea;
|
||||
cout << "Entrez la note Eb : ";
|
||||
cin >> Eb;
|
||||
|
||||
return (Ea + Eb);
|
||||
}
|
||||
43
TP1/1.4.cpp
Normal file
43
TP1/1.4.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Saisie(const int dim, int &S, int A[]);
|
||||
void Affichage(int S, const int A[]);
|
||||
|
||||
void main()
|
||||
{
|
||||
const int dim = 7;
|
||||
int i, A[dim], S = 0;
|
||||
|
||||
Saisie(dim, S, A);
|
||||
Affichage(dim, A);
|
||||
|
||||
/*S = 0;
|
||||
for (i = 0; i < 7;i++) {
|
||||
S += A[i];
|
||||
}*/
|
||||
cout << "\nLa somme est = " << S << "\n";
|
||||
}
|
||||
|
||||
void Saisie(const int dim, int &S, int A[])
|
||||
{
|
||||
cout << "Saisie:\n";
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
cout << "Entrez A[" << i << "]= ";
|
||||
cin >> A[i];
|
||||
S += A[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Affichage(const int dim, const int A[])
|
||||
{
|
||||
cout << "Affichage:\n";
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
cout << "A[" << i << "]=" << A[i] << "\n";
|
||||
}
|
||||
}
|
||||
82
TP2/2.1.cpp
Normal file
82
TP2/2.1.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Fct1();
|
||||
void Fct2(int &A);
|
||||
void Fct3(int A);
|
||||
void Fct4(float &B, char &C, string &D);
|
||||
void Fct5(float B, char C, string D);
|
||||
string Fct6(float B, char C, string D);
|
||||
|
||||
// ostream &(*pfs)(ostream &o)Fct6Bis(float B, char C, string D);
|
||||
|
||||
function<ostream &(ostream &)> Fct6Bis(float B, char C, string D);
|
||||
|
||||
void main()
|
||||
{
|
||||
int A;
|
||||
float B;
|
||||
char C;
|
||||
string D;
|
||||
|
||||
Fct1();
|
||||
Fct2(A);
|
||||
Fct3(A);
|
||||
Fct4(B, C, D);
|
||||
Fct5(B, C, D);
|
||||
cout << "Voici la solution de cette fonction" << Fct6(B, C, D);
|
||||
cout << "\n";
|
||||
// cout << "Voici la solution de cette fonction (bis)" << Fct6Bis(B, C, D);
|
||||
}
|
||||
|
||||
void Fct1()
|
||||
{
|
||||
cout << "Bonjour" << endl;
|
||||
}
|
||||
|
||||
void Fct2(int &A)
|
||||
{
|
||||
cout << "Entrez la valeur de l'entier A : ";
|
||||
cin >> A;
|
||||
}
|
||||
|
||||
void Fct3(int A)
|
||||
{
|
||||
cout << "Le double de A vaut : " << (A * 2) << endl;
|
||||
}
|
||||
|
||||
void Fct4(float &B, char &C, string &D)
|
||||
{
|
||||
cout << "Entrez la valeur du float B : ";
|
||||
cin >> B;
|
||||
cout << "Entrez la valeur du char C : ";
|
||||
cin >> C;
|
||||
cout << "Entrez la valeur du string D : ";
|
||||
// cin.getline(D);
|
||||
cin >> D;
|
||||
}
|
||||
|
||||
void Fct5(float B, char C, string D)
|
||||
{
|
||||
cout << "La valeur de B vaut : " << B << endl;
|
||||
cout << "La valeur de C vaut : " << C << endl;
|
||||
cout << "La valeur de D vaut : " << D << endl;
|
||||
}
|
||||
|
||||
string Fct6(float B, char C, string D)
|
||||
{
|
||||
return " La valeur de B vaut : " + to_string(B) + ", " + "La valeur de C vaut : " + to_string(C) + ", " + "La valeur de D vaut : " + D + ".";
|
||||
}
|
||||
|
||||
function<ostream &(ostream &)> Fct6Bis(float B, char C, string D)
|
||||
{
|
||||
auto a = [](ostream &o) -> ostream &
|
||||
{
|
||||
return o << "HelloWorld";
|
||||
};
|
||||
|
||||
return a;
|
||||
}
|
||||
28
TP2/2.2.cpp
Normal file
28
TP2/2.2.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int pow(int base, int exp);
|
||||
|
||||
void main()
|
||||
{
|
||||
int P1, P2, P3;
|
||||
|
||||
P1 = pow(5, 3);
|
||||
P2 = pow(7, 9);
|
||||
P3 = pow(3, 21);
|
||||
|
||||
cout << "\nLa puissance P1 est = " << P1;
|
||||
cout << "\nLa puissance P2 est = " << P2;
|
||||
cout << "\nLa puissance P2 est = " << P2;
|
||||
}
|
||||
|
||||
int pow(int base, int exp)
|
||||
{
|
||||
int r = 1;
|
||||
while (exp-- > 0)
|
||||
{
|
||||
r *= base;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
52
TP2/2.3.cpp
Normal file
52
TP2/2.3.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 100;
|
||||
|
||||
void Saisie(int tab[], int &n, int &S, float &Moy);
|
||||
void Affichage(int tab[], int n, int S, float Moy);
|
||||
|
||||
void main()
|
||||
{
|
||||
int N, S;
|
||||
float Moy;
|
||||
int Tab[Nmax];
|
||||
|
||||
Saisie(Tab, N, S, Moy);
|
||||
Affichage(Tab, N, S, Moy);
|
||||
}
|
||||
|
||||
void Saisie(int tab[], int &n, int &S, float &Moy)
|
||||
{
|
||||
cout << "Entrez la taille du tableau : ";
|
||||
cin >> n;
|
||||
|
||||
if (n > Nmax)
|
||||
{
|
||||
n = Nmax;
|
||||
cout << "La taille maximale du tableau est de " << Nmax;
|
||||
}
|
||||
|
||||
S = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cout << "tab[" << i << "]" << " = ";
|
||||
cin >> tab[i];
|
||||
S += tab[i];
|
||||
}
|
||||
|
||||
Moy = S / (float)n;
|
||||
}
|
||||
|
||||
void Affichage(int tab[], int n, int S, float Moy)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cout << "tab[" << i << "]" << " = " << tab[i] << endl;
|
||||
}
|
||||
|
||||
cout << "Somme = " << S << endl;
|
||||
cout << "Moyenne = " << Moy << endl;
|
||||
}
|
||||
65
TP2/2.4.cpp
Normal file
65
TP2/2.4.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 10;
|
||||
|
||||
void Saisie(int tab[][Nmax], int &n1, int &n2, int &S, float &Moy);
|
||||
void Affichage(int tab[][Nmax], int n1, int n2, int S, float Moy);
|
||||
|
||||
void main()
|
||||
{
|
||||
int N1, N2, S;
|
||||
float Moy;
|
||||
int Tab[Nmax][Nmax];
|
||||
// i*n1 + j
|
||||
Saisie(Tab, N1, N2, S, Moy);
|
||||
Affichage(Tab, N1, N2, S, Moy);
|
||||
}
|
||||
|
||||
void Saisie(int tab[][Nmax], int &n1, int &n2, int &S, float &Moy)
|
||||
{
|
||||
cout << "Entrez le nombre de lignes : ";
|
||||
cin >> n1;
|
||||
cout << "Entrez le nombre de colonnes : ";
|
||||
cin >> n2;
|
||||
|
||||
if (n1 > Nmax)
|
||||
{
|
||||
n1 = Nmax;
|
||||
cout << "La taille maximale du tableau est de " << Nmax;
|
||||
}
|
||||
if (n2 > Nmax)
|
||||
{
|
||||
n2 = Nmax;
|
||||
cout << "La taille maximale du tableau est de " << Nmax;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n1; i++)
|
||||
{
|
||||
for (int j = 0; j < n2; j++)
|
||||
{
|
||||
cout << "tab[" << i << "]" << "[" << j << "]" << " = ";
|
||||
cin >> tab[i][j];
|
||||
S += tab[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
Moy = (float)S / (n1 + n2);
|
||||
}
|
||||
|
||||
void Affichage(int tab[][Nmax], int n1, int n2, int S, float Moy)
|
||||
{
|
||||
for (int i = 0; i < n1; i++)
|
||||
{
|
||||
for (int j = 0; j < n2; j++)
|
||||
{
|
||||
cout << tab[i][j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
// cout << "tab[" << i << "]" << " = " << tab[i] << endl;
|
||||
}
|
||||
|
||||
cout << "Somme = " << S << endl;
|
||||
cout << "Moyenne = " << Moy << endl;
|
||||
}
|
||||
123
TP3/3.1.cpp
Normal file
123
TP3/3.1.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 10;
|
||||
|
||||
struct PROF
|
||||
{
|
||||
int Id;
|
||||
string nom;
|
||||
string service;
|
||||
};
|
||||
|
||||
void SaisieProf(PROF &prof);
|
||||
void AfficherProf(const PROF prof);
|
||||
|
||||
template <typename T>
|
||||
void DeplacerDroite(T tab[], int N, int i = 0)
|
||||
{
|
||||
while (N-- > i)
|
||||
{
|
||||
tab[N + 1 + i] = tab[N + i];
|
||||
}
|
||||
}
|
||||
|
||||
int ChercherProf(const PROF profs[], const int N, string name, string service);
|
||||
|
||||
int menu()
|
||||
{
|
||||
int choix;
|
||||
|
||||
cout
|
||||
<< " 1. Saisir + Afficher\n"
|
||||
<< " 2. Ajouter un PROF au début + Afficher\n"
|
||||
<< " 3. Chercher si PROF1 existe ou pas dans le tableau\n"
|
||||
<< " 4. Quitter " << "\n"
|
||||
<< " 5. Afficher la liste de profs\n"
|
||||
<< "Entrez votre choix : ";
|
||||
|
||||
cin >> choix;
|
||||
|
||||
return choix;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
PROF profs[Nmax];
|
||||
int choix = 0, N = 0;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (choix != 4)
|
||||
{
|
||||
switch (choix = menu())
|
||||
{
|
||||
case 1:
|
||||
SaisieProf(profs[N]);
|
||||
AfficherProf(profs[N++]);
|
||||
break;
|
||||
case 2:
|
||||
DeplacerDroite(profs, N);
|
||||
N++;
|
||||
SaisieProf(profs[0]);
|
||||
AfficherProf(profs[0]);
|
||||
break;
|
||||
case 3:
|
||||
if (ChercherProf(profs, N, "PROF1", "SERVICE1") != -1)
|
||||
{
|
||||
cout << "Le PROF1 est dans la liste" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Le PROF1 n'est pas dans la liste" << "\n";
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
return;
|
||||
case 5:
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
cout << "-- Prof " << i << " --" << endl;
|
||||
AfficherProf(profs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SaisieProf(PROF &prof)
|
||||
{
|
||||
cout << "Identifiant: ";
|
||||
cin >> prof.Id;
|
||||
cin.ignore();
|
||||
cout << "Nom : \n";
|
||||
// cin.ignore();
|
||||
|
||||
// cin >> prof.nom;
|
||||
getline(cin, prof.nom);
|
||||
cout << "Service : \n";
|
||||
// cin.ignore();
|
||||
getline(cin, prof.service);
|
||||
// cin >> prof.service;
|
||||
}
|
||||
|
||||
void AfficherProf(const PROF prof)
|
||||
{
|
||||
cout << "Prof " << prof.Id << "\n"
|
||||
<< "Nom : " << prof.nom << "\n"
|
||||
<< "Service : " << prof.service << "\n";
|
||||
}
|
||||
|
||||
int ChercherProf(const PROF profs[], int N, string name, string service)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (profs[i].nom == name && profs[i].service == service)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
122
TP3/3.2.cpp
Normal file
122
TP3/3.2.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 10;
|
||||
|
||||
struct PROF
|
||||
{
|
||||
int Id;
|
||||
string nom;
|
||||
string service;
|
||||
|
||||
void saisie();
|
||||
void afficher();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void DeplacerDroite(T tab[], int N, int i = 0)
|
||||
{
|
||||
while (N-- > i)
|
||||
{
|
||||
tab[N + 1 + i] = tab[N + i];
|
||||
}
|
||||
}
|
||||
|
||||
int ChercherProf(const PROF profs[], const int N, string name, string service);
|
||||
|
||||
int menu()
|
||||
{
|
||||
int choix;
|
||||
|
||||
cout
|
||||
<< " 1. Saisir + Afficher\n"
|
||||
<< " 2. Ajouter un PROF au d<>but + Afficher\n"
|
||||
<< " 3. Chercher si PROF1 existe ou pas dans le tableau\n"
|
||||
<< " 4. Quitter " << "\n"
|
||||
<< " 5. Afficher la liste de profs\n"
|
||||
<< "Entrez votre choix : ";
|
||||
|
||||
cin >> choix;
|
||||
|
||||
return choix;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
PROF profs[Nmax];
|
||||
int choix = 0, N = 0;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (choix != 4)
|
||||
{
|
||||
switch (choix = menu())
|
||||
{
|
||||
case 1:
|
||||
profs[N].saisie();
|
||||
profs[N++].afficher();
|
||||
break;
|
||||
case 2:
|
||||
DeplacerDroite(profs, N);
|
||||
N++;
|
||||
profs[0].saisie();
|
||||
profs[0].afficher();
|
||||
break;
|
||||
case 3:
|
||||
if (ChercherProf(profs, N, "PROF1", "SERVICE1") != -1)
|
||||
{
|
||||
cout << "Le PROF1 est dans la liste" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Le PROF1 n'est pas dans la liste" << "\n";
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
return;
|
||||
case 5:
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
cout << "-- Prof " << i << " --" << endl;
|
||||
profs[i].afficher();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PROF::saisie()
|
||||
{
|
||||
cout << "Identifiant: ";
|
||||
cin >> Id;
|
||||
cin.ignore();
|
||||
cout << "Nom : \n";
|
||||
|
||||
// cin >> prof.nom;
|
||||
getline(cin, nom);
|
||||
cout << "Service : \n";
|
||||
// cin.ignore();
|
||||
getline(cin, service);
|
||||
// cin >> prof.service;
|
||||
}
|
||||
|
||||
void PROF::afficher()
|
||||
{
|
||||
cout << "Prof " << Id << "\n"
|
||||
<< "Nom : " << nom << "\n"
|
||||
<< "Service : " << service << "\n";
|
||||
}
|
||||
|
||||
int ChercherProf(const PROF profs[], int N, string name, string service)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (profs[i].nom == name && profs[i].service == service)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
156
TP3/3.3.cpp
Normal file
156
TP3/3.3.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Nmax = 10;
|
||||
|
||||
struct PROF
|
||||
{
|
||||
int Id;
|
||||
string nom;
|
||||
string service;
|
||||
|
||||
PROF();
|
||||
|
||||
void saisie();
|
||||
void afficher();
|
||||
|
||||
static int counter;
|
||||
|
||||
bool operator==(PROF P)
|
||||
{
|
||||
return P.nom == nom && P.service == service;
|
||||
}
|
||||
};
|
||||
|
||||
int PROF::counter = 0;
|
||||
|
||||
template <typename T>
|
||||
void DeplacerDroite(T tab[], int N, int i = 0)
|
||||
{
|
||||
PROF tmp = tab[Nmax - 1];
|
||||
while (N-- > i)
|
||||
{
|
||||
tab[N + 1 + i] = tab[N + i];
|
||||
}
|
||||
tab[0] = tmp;
|
||||
}
|
||||
|
||||
int ChercherProf(PROF profs[], const int N, PROF p);
|
||||
|
||||
int menu()
|
||||
{
|
||||
int choix;
|
||||
|
||||
cout
|
||||
<< " 1. Saisir + Afficher\n"
|
||||
<< " 2. Ajouter un PROF au début + Afficher\n"
|
||||
<< " 3. Chercher si un prof existe ou pas dans le tableau\n"
|
||||
<< " 4. Quitter " << "\n"
|
||||
<< " 5. Afficher la liste de profs\n"
|
||||
<< "Entrez votre choix : ";
|
||||
|
||||
cin >> choix;
|
||||
|
||||
return choix;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
PROF profs[Nmax];
|
||||
PROF p;
|
||||
int choix = 0, N = 0;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (choix != 4)
|
||||
{
|
||||
switch (choix = menu())
|
||||
{
|
||||
case 1:
|
||||
if (N >= 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
profs[N].saisie();
|
||||
profs[N++].afficher();
|
||||
break;
|
||||
case 2:
|
||||
if (N >= 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
DeplacerDroite(profs, Nmax);
|
||||
N++;
|
||||
profs[0].saisie();
|
||||
profs[0].afficher();
|
||||
break;
|
||||
case 3:
|
||||
cout << "Entrez le nom du prof à rechercher : \n";
|
||||
cin.ignore();
|
||||
getline(cin, p.nom);
|
||||
cout << "Entrez le nom du service du prof à rechercher : \n";
|
||||
// cin.ignore();
|
||||
getline(cin, p.service);
|
||||
// cout << "Service:" << p.service << "\n";
|
||||
if (ChercherProf(profs, N, p) != -1)
|
||||
{
|
||||
cout << "Le " << p.nom << " est dans la liste" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Le " << p.nom << " n'est pas dans la liste" << "\n";
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
return;
|
||||
case 5:
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
cout << "-- Prof " << i << " --" << endl;
|
||||
profs[i].afficher();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROF::PROF()
|
||||
{
|
||||
Id = ++counter;
|
||||
}
|
||||
|
||||
void PROF::saisie()
|
||||
{
|
||||
|
||||
cout << "Nom : ";
|
||||
cin.ignore();
|
||||
// cin >> prof.nom;
|
||||
getline(cin, nom);
|
||||
cout << "Service : ";
|
||||
// cin.ignore();
|
||||
getline(cin, service);
|
||||
// cin >> prof.service;
|
||||
}
|
||||
|
||||
void PROF::afficher()
|
||||
{
|
||||
cout << "Prof " << Id << "\n"
|
||||
<< "Nom : " << nom << "\n"
|
||||
<< "Service : " << service << "\n";
|
||||
}
|
||||
|
||||
int ChercherProf(PROF profs[], int N, PROF P)
|
||||
{
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (profs[i] == P)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
325
TP4/4.cpp
Normal file
325
TP4/4.cpp
Normal file
@@ -0,0 +1,325 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ETUD
|
||||
{
|
||||
// nombre d'instances;
|
||||
static int compteur;
|
||||
|
||||
int Id;
|
||||
string nom;
|
||||
|
||||
public:
|
||||
ETUD() : Id(++compteur) {};
|
||||
|
||||
~ETUD()
|
||||
{
|
||||
cout << "Disparition d'un étudiant (Id=" << Id << ") \n";
|
||||
};
|
||||
|
||||
void saisie();
|
||||
void affiche();
|
||||
|
||||
static void afficheEnLigneEnTete();
|
||||
void afficheEnLigne();
|
||||
|
||||
void lire(ifstream &s);
|
||||
};
|
||||
|
||||
class PROF
|
||||
{
|
||||
// nombre d'instances;
|
||||
static int compteur;
|
||||
|
||||
int Id;
|
||||
string nom, service;
|
||||
|
||||
public:
|
||||
PROF() : Id(++compteur) {};
|
||||
// passer une variable dans ce constructeur
|
||||
// créée un prof "temporaire"
|
||||
// cela signifie que son destructeur n'affichera rien
|
||||
// dans la console
|
||||
PROF(bool) : Id(-1) {};
|
||||
~PROF()
|
||||
{
|
||||
if (Id == -1)
|
||||
return;
|
||||
cout << "Disparition d'un prof (Id=" << Id << ")\n";
|
||||
}
|
||||
|
||||
void saisie();
|
||||
void affiche();
|
||||
|
||||
static void afficheEnLigneEnTete();
|
||||
void afficheEnLigne();
|
||||
|
||||
void lire(ifstream &s);
|
||||
|
||||
bool operator==(PROF &p);
|
||||
};
|
||||
|
||||
// initialisation des variables statiques
|
||||
// sur les structures
|
||||
// cela permet d'écrire
|
||||
// : Id(++compteur)
|
||||
// dans le constructeur
|
||||
// au lieu de
|
||||
// {
|
||||
// static int compteur = 0;
|
||||
// Id = ++compteur;
|
||||
// }
|
||||
int PROF::compteur = 0;
|
||||
int ETUD::compteur = 0;
|
||||
|
||||
template <typename T>
|
||||
int lire_fichier(vector<T> &tab, const string filename)
|
||||
{
|
||||
ifstream file(filename);
|
||||
int N;
|
||||
|
||||
if (!file.is_open())
|
||||
{
|
||||
// code d'erreur de la fonction
|
||||
return -1;
|
||||
}
|
||||
|
||||
file >> N;
|
||||
file.ignore();
|
||||
int i = 0;
|
||||
while (!file.eof())
|
||||
{
|
||||
// créer un nouvel étudiant/prof
|
||||
// "emplace" pour éviter d'appeller le constructeur lors de la création de l'objet
|
||||
// et ensuite lors de la copie dans l'ajout dans le vecteur (destructeur->constructeur)
|
||||
tab.emplace_back();
|
||||
tab.back().lire(file);
|
||||
file.ignore();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Affiche le vecteur via la fonction "affichage" du
|
||||
// type générique
|
||||
template <typename T>
|
||||
void affiche(vector<T> &vec)
|
||||
{
|
||||
for (auto it = vec.begin(); it != vec.end(); ++it)
|
||||
{
|
||||
(*it).affiche();
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche le vecteur en formattage colonne
|
||||
// En appellant la fonction statique "EnTete"
|
||||
// Et ensuite ligne par ligne la fonction
|
||||
// afficheEnLigne
|
||||
template <typename T>
|
||||
void affiche_ligne(vector<T> &vec)
|
||||
{
|
||||
T::afficheEnLigneEnTete();
|
||||
cout << "\n";
|
||||
for (auto &el : vec)
|
||||
{
|
||||
el.afficheEnLigne();
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void saisir_debut(vector<T> &vec)
|
||||
{
|
||||
// créer un objet (constructeur)
|
||||
vec.emplace(vec.begin());
|
||||
|
||||
vec.front().saisie();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int recherche(vector<T> &vec)
|
||||
{
|
||||
// passage d'un booléen pour
|
||||
// appeller le 2e constructeur
|
||||
// d'objet "temporaires" (Id=-1, pas d'appel du déstructeur)
|
||||
T p(true);
|
||||
p.saisie();
|
||||
for (auto it = vec.begin(); it != vec.end(); it++)
|
||||
{
|
||||
if (p == (*it))
|
||||
{
|
||||
return it - vec.begin();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int menu()
|
||||
{
|
||||
int choix;
|
||||
cout << "--Menu--\n"
|
||||
<< " 1. Lire fichier PROF + Lire fichier ETUD +Afficher les deux tableaux\n"
|
||||
<< " 2. Ajouter un PROF au début du tableau + Afficher\n"
|
||||
<< " 3. Ajouter un ETUD au début du tableau + Afficher\n"
|
||||
<< " 4. Chercher PROF1 dans le tableau des PROF et le supprimer s'il existe\n"
|
||||
<< " 5. Quitter " << endl;
|
||||
cout << "Votre choix : ";
|
||||
cin >> choix;
|
||||
return choix;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<ETUD> etudiants;
|
||||
etudiants.reserve(20);
|
||||
|
||||
vector<PROF> profs;
|
||||
profs.reserve(20);
|
||||
|
||||
// list<ETUD> etudiants;
|
||||
// list<PROF> profs;
|
||||
|
||||
bool fichier_lu = false;
|
||||
// int i;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (menu())
|
||||
{
|
||||
case 1:
|
||||
if (fichier_lu)
|
||||
{
|
||||
cout << "Le fichier à déjà été lu" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
if (lire_fichier(etudiants, "ETUD.txt") != 0)
|
||||
{
|
||||
cout << "Une erreur est survenue lors de la lecture du fichier ETUD.txt" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lire_fichier(profs, "PROF.txt") != 0)
|
||||
{
|
||||
cout << "Une erreur est survenue lors de la lecture du fichier PROF.txt" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
cout << "-- Liste des étudiants (" << etudiants.size() << ") --" << endl;
|
||||
affiche_ligne(etudiants);
|
||||
|
||||
cout << "-- Liste des profs (" << profs.size() << ") --" << endl;
|
||||
affiche_ligne(profs);
|
||||
|
||||
fichier_lu = true;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
saisir_debut(profs);
|
||||
affiche_ligne(profs);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
saisir_debut(etudiants);
|
||||
affiche_ligne(etudiants);
|
||||
break;
|
||||
case 4:
|
||||
if (int i = recherche(profs) != -1)
|
||||
{
|
||||
cout << "Le prof cherché existe en position " << i << " et sera supprimé !" << endl;
|
||||
profs.erase(profs.begin() + i);
|
||||
affiche_ligne(profs);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Le prof n'est pas dans la liste :(" << endl;
|
||||
}
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ETUD::saisie()
|
||||
{
|
||||
cin.ignore();
|
||||
cout << "Quel est le nom?: ";
|
||||
getline(cin, nom);
|
||||
}
|
||||
|
||||
void ETUD::affiche()
|
||||
{
|
||||
cout << "Etudiant ID: " << Id << "\n";
|
||||
cout << "Nom: " << nom << "\n";
|
||||
}
|
||||
|
||||
void ETUD::afficheEnLigneEnTete()
|
||||
{
|
||||
cout << "Id " << " " << "Nom";
|
||||
}
|
||||
|
||||
void ETUD::afficheEnLigne()
|
||||
{
|
||||
cout << left << setw(10) << Id;
|
||||
cout << " " << nom;
|
||||
}
|
||||
|
||||
void ETUD::lire(ifstream &i)
|
||||
{
|
||||
i >> nom;
|
||||
// std::getline(i, nom, '\n');
|
||||
}
|
||||
|
||||
void PROF::saisie()
|
||||
{
|
||||
cin.ignore();
|
||||
cout << "Quel est le nom?: ";
|
||||
getline(cin, nom);
|
||||
|
||||
cout << "Quel est le service?: ";
|
||||
getline(cin, service);
|
||||
}
|
||||
|
||||
void PROF::affiche()
|
||||
{
|
||||
cout << "Prof ID: " << Id << "\n";
|
||||
cout << "Nom: " << nom << "\n";
|
||||
cout << "Service: " << service << "\n";
|
||||
}
|
||||
|
||||
void PROF::lire(ifstream &s)
|
||||
{
|
||||
std::getline(s, nom, ';');
|
||||
std::getline(s, service, ';');
|
||||
}
|
||||
|
||||
void PROF::afficheEnLigneEnTete()
|
||||
{
|
||||
cout << "Id " << " Nom " << " Service";
|
||||
}
|
||||
|
||||
void PROF::afficheEnLigne()
|
||||
{
|
||||
cout << left << setw(10) << Id;
|
||||
cout << " " << left << setw(8) << nom;
|
||||
cout << " " << service;
|
||||
}
|
||||
|
||||
bool PROF::operator==(PROF &p)
|
||||
{
|
||||
return nom == p.nom && service == p.service;
|
||||
}
|
||||
9
TP5/ETUDB.txt
Normal file
9
TP5/ETUDB.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
7
|
||||
Etud1
|
||||
Etud2
|
||||
Etud3
|
||||
Etud4
|
||||
Etud5
|
||||
Etud6
|
||||
Etud7
|
||||
6
TP5/PROF.txt
Normal file
6
TP5/PROF.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
5
|
||||
Prof1;Informatique;
|
||||
Prof2;Informatique;
|
||||
Prof3;Mathematique;
|
||||
Prof4;Physique;
|
||||
Prof5;Chimie;
|
||||
9
TP5/PROF.xsd
Normal file
9
TP5/PROF.xsd
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema id="PROF"
|
||||
targetNamespace="http://tempuri.org/PROF.xsd"
|
||||
elementFormDefault="qualified"
|
||||
xmlns="http://tempuri.org/PROF.xsd"
|
||||
xmlns:mstns="http://tempuri.org/PROF.xsd"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
>
|
||||
</xs:schema>
|
||||
31
TP5/TP5.sln
Normal file
31
TP5/TP5.sln
Normal 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}") = "TP5", "TP5.vcxproj", "{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}"
|
||||
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
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Debug|x64.Build.0 = Debug|x64
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Debug|x86.Build.0 = Debug|Win32
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Release|x64.ActiveCfg = Release|x64
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Release|x64.Build.0 = Release|x64
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Release|x86.ActiveCfg = Release|Win32
|
||||
{5ED86EF3-56FC-47BB-8158-B3DA0C5C17C9}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {751FCA9B-3D1B-4953-B0CB-D7CA089CBB38}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
139
TP5/TP5.vcxproj
Normal file
139
TP5/TP5.vcxproj
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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>{5ed86ef3-56fc-47bb-8158-b3da0c5c17c9}</ProjectGuid>
|
||||
<RootNamespace>TP5</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>
|
||||
<ItemGroup>
|
||||
<Text Include="ETUDB.txt" />
|
||||
<Text Include="PROF.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
TP5/TP5.vcxproj.filters
Normal file
30
TP5/TP5.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<ItemGroup>
|
||||
<Text Include="PROF.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="ETUDB.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP5/TP5.vcxproj.user
Normal file
4
TP5/TP5.vcxproj.user
Normal 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>
|
||||
215
TP5/main.cpp
Normal file
215
TP5/main.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ETUD {
|
||||
int Id;
|
||||
string nom;
|
||||
|
||||
public:
|
||||
ETUD() { static int i = 0; Id = ++i; }
|
||||
~ETUD() { cout << "Disparition de l'étudiant ID=" << Id << endl; }
|
||||
|
||||
void saisie(string ligne) { nom = ligne.substr(0, ligne.find(';')); };
|
||||
void affiche() { cout << setw(4) << Id << left << setw(2) << nom; }
|
||||
void saisie() { cout << "Nom :"; cin.ignore(); getline(cin, nom); }
|
||||
|
||||
string getNom() { return nom; }
|
||||
};
|
||||
|
||||
class PROF {
|
||||
int Id;
|
||||
string nom, service;
|
||||
|
||||
public:
|
||||
PROF() { static int i = 0; Id = ++i; }
|
||||
~PROF() { cout << "Disparition du prof ID=" << Id << endl; }
|
||||
|
||||
void saisie(string ligne) { int i = ligne.find(';'); nom = ligne.substr(0, i); service = ligne.substr(i + 1, ligne.find(';', i+1) - i - 1); };
|
||||
void affiche() { cout << left << setw(4) << Id << left << setw(8) << nom << " " << left << setw(8) << service; }
|
||||
void saisie() { cout << "Nom :"; cin.ignore(); getline(cin, nom); cout << "Service :"; cin.ignore(); getline(cin, service); }
|
||||
|
||||
string getNom() { return nom; }
|
||||
};
|
||||
|
||||
int menu() {
|
||||
int choix;
|
||||
cout << "Entrez votre choix : \n"
|
||||
<< " 1. Lire fichier PROF et stocker les données dans un Vector + Affichage\n"
|
||||
<< " 2. Lire fichier ETUDB et stocker les données dans une List + Affichage\n"
|
||||
<< " 3. Ajouter un PROF au début du Vector + Afficher\n"
|
||||
<< " 4. Ajouter un ETUD au début de List + Afficher\n"
|
||||
<< " 5. Supprimer le PROF et ETUD au début de Vector et List + Affichage\n"
|
||||
<< " 6. Créer une List2 contenant uniquement les noms des ETUD et PROF \n"
|
||||
<< " 7. Quitter " << endl;
|
||||
cin >> choix;
|
||||
return choix;
|
||||
}
|
||||
|
||||
// template <class C, class O>
|
||||
template <class C>
|
||||
void lire(C& c, string nomfichier) {
|
||||
ifstream fichier(nomfichier);
|
||||
int N;
|
||||
string ligne;
|
||||
|
||||
if (!fichier) {
|
||||
cout << "Une erreur est survenue lors de la lecture du fichier" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
fichier >> N;
|
||||
fichier.ignore();
|
||||
while (N-- > 0) {
|
||||
getline(fichier, ligne);
|
||||
// O o;
|
||||
// o.saisie(ligne);
|
||||
// c.insert(c.end(), o);
|
||||
|
||||
// https://cplusplus.com/reference/vector/vector/emplace/
|
||||
// https://cplusplus.com/reference/list/list/emplace/
|
||||
c.emplace(c.end())->saisie(ligne);
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void affiche(C& conteneur) {
|
||||
cout << "Ce conteneur contient" << endl;
|
||||
for (auto& o : conteneur) {
|
||||
cout << endl;
|
||||
o.affiche();
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void lire_puis_affiche(C& conteneur, string nomfichier) {
|
||||
lire(conteneur, nomfichier);
|
||||
affiche(conteneur);
|
||||
}
|
||||
|
||||
// template <class C, class O>
|
||||
template <class C>
|
||||
void ajoutdebut_affiche(C& conteneur) {
|
||||
conteneur.emplace(conteneur.begin())->saisie();
|
||||
affiche(conteneur);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void supprimedebut_affiche(C& conteneur) {
|
||||
conteneur.erase(conteneur.begin());
|
||||
affiche(conteneur);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void remplirliste_nom(C& c, list<string>& l) {
|
||||
for (auto& o : c) {
|
||||
l.push_back(o.getNom());
|
||||
}
|
||||
}
|
||||
|
||||
void affiche(list<string>& l) {
|
||||
cout << "Voici la liste des noms des etudiants et des PROFs" << endl;
|
||||
for (auto& o : l) {
|
||||
cout << endl << o;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
list<ETUD> etuds;
|
||||
vector<PROF> profs;
|
||||
|
||||
list<string> list2;
|
||||
|
||||
profs.reserve(10);
|
||||
|
||||
int choix;
|
||||
|
||||
while ((choix = menu()) != 7) {
|
||||
switch (choix) {
|
||||
case 1:
|
||||
//lire<vector<PROF>, PROF>(profs, "PROF.txt");
|
||||
lire_puis_affiche(profs, "PROF.txt");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//lire<list<ETUD>, ETUD>(etuds, "ETUDB.txt");
|
||||
lire_puis_affiche(etuds, "ETUDB.txt");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ajoutdebut_affiche(profs);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
ajoutdebut_affiche(etuds);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
supprimedebut_affiche(etuds);
|
||||
supprimedebut_affiche(profs);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
remplirliste_nom(etuds, list2);
|
||||
remplirliste_nom(profs, list2);
|
||||
affiche(list2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
template <class Conteneur, class T>
|
||||
void fonction_template(Conteneur& conteneur) {
|
||||
T monobjet;
|
||||
|
||||
conteneur.push_back(monobjet);
|
||||
}
|
||||
|
||||
void exemple_template() {
|
||||
list<PROF> profs;
|
||||
profs.push_back
|
||||
|
||||
int varI = 0;
|
||||
|
||||
fonction_template<list<PROF>, PROF>(profs);
|
||||
|
||||
fonction_template<list<PROF>, string>(profs);
|
||||
|
||||
fonction_template<int, string>(varI);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// expand la fonction template comme ceci
|
||||
void fonction_template(list<PROF>& conteneur) {
|
||||
PROF monobjet;
|
||||
|
||||
conteneur.push_back(monobjet);
|
||||
}
|
||||
|
||||
// expand la fonction template comme ceci (avec le 2e)
|
||||
void fonction_template(list<PROF>& conteneur) {
|
||||
string monobjet;
|
||||
|
||||
conteneur.push_back(monobjet);
|
||||
}
|
||||
|
||||
// expand la fonction template comme ceci (avec le 3e)
|
||||
void fonction_template(int& conteneur) {
|
||||
string monobjet;
|
||||
|
||||
conteneur.push_back(monobjet);
|
||||
}*/
|
||||
31
TP6/TP6.sln
Normal file
31
TP6/TP6.sln
Normal 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}") = "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
|
||||
135
TP6/TP6.vcxproj
Normal file
135
TP6/TP6.vcxproj
Normal 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>{c1ce1082-4eb0-43d9-8755-76fb40ff79ce}</ProjectGuid>
|
||||
<RootNamespace>TP6</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>
|
||||
22
TP6/TP6.vcxproj.filters
Normal file
22
TP6/TP6.vcxproj.filters
Normal 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>
|
||||
4
TP6/TP6.vcxproj.user
Normal file
4
TP6/TP6.vcxproj.user
Normal 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>
|
||||
279
TP6/main.cpp
Normal file
279
TP6/main.cpp
Normal file
@@ -0,0 +1,279 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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<Etudiant> etudiants;
|
||||
vector<Prof> 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;
|
||||
}
|
||||
277
TP6/main.cpp.txt
Normal file
277
TP6/main.cpp.txt
Normal file
@@ -0,0 +1,277 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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 <class C>
|
||||
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<Etudiant> etudiants;
|
||||
vector<Prof> 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;
|
||||
}
|
||||
39
TP7/Entreprise.cpp
Normal file
39
TP7/Entreprise.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "Entreprise.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Entreprise::saisie(ifstream& s) {
|
||||
string tmp;
|
||||
|
||||
getline(s, m_company, ';');
|
||||
getline(s, m_country, ';');
|
||||
getfloat(s, m_market_value, ';');
|
||||
getline(s, m_sector, ';');
|
||||
getfloat(s, m_turnover, ';');
|
||||
getfloat(s, m_employees, ';');
|
||||
getint(s, m_rank_2015, ';');
|
||||
getint(s, m_rank_2014, ';');
|
||||
}
|
||||
|
||||
void Entreprise::affichage() {
|
||||
format(m_company, 20);
|
||||
format(m_country, 15);
|
||||
format(m_market_value, 10);
|
||||
format(m_sector, 10);
|
||||
format(m_turnover, 10);
|
||||
format(m_employees, 6);
|
||||
format(m_rank_2015, 3);
|
||||
format(m_rank_2014, 3);
|
||||
}
|
||||
|
||||
int Entreprise::rank_progress() const {
|
||||
return m_rank_2014 - m_rank_2015;
|
||||
}
|
||||
|
||||
float Entreprise::turnover_empl() const {
|
||||
return (float)m_turnover / m_employees;
|
||||
}
|
||||
|
||||
float Entreprise::getTurnover() const {
|
||||
return m_turnover;
|
||||
}
|
||||
29
TP7/Entreprise.h
Normal file
29
TP7/Entreprise.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "getio.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Entreprise {
|
||||
string m_company; //(Nom de la Société) clé
|
||||
string m_country; //(Nom du Pays)
|
||||
float m_market_value; //(Valeur Marchande)
|
||||
string m_sector; //(Secteur d’Activité)
|
||||
float m_turnover; //(Chiffre d’Affaire)
|
||||
float m_employees; //(Nombre d’Employés)
|
||||
int m_rank_2015; //(Rang en 2015)
|
||||
int m_rank_2014; //(Rang en 2014)
|
||||
|
||||
public:
|
||||
void saisie(ifstream&);
|
||||
void affichage();
|
||||
|
||||
int rank_progress() const;
|
||||
float turnover_empl() const;
|
||||
float getTurnover() const;
|
||||
|
||||
string key() { return m_company; }
|
||||
};
|
||||
25
TP7/Pays.cpp
Normal file
25
TP7/Pays.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#include "Pays.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "getio.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Pays::saisie(ifstream &in) {
|
||||
getline(in, Region, ';');
|
||||
getline(in, Nom, ';');
|
||||
|
||||
getfloat(in, Population, ';');
|
||||
getfloat(in, Area, ';');
|
||||
}
|
||||
|
||||
void Pays::affichage() {
|
||||
// format(Region, 10);
|
||||
format(Nom, 20);
|
||||
cout << setprecision(10);
|
||||
format(Population, 10);
|
||||
format(Area, 10);
|
||||
// << setprecision(10) << Population << " " << Area;
|
||||
}
|
||||
20
TP7/Pays.h
Normal file
20
TP7/Pays.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "getio.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Pays {
|
||||
string Region; // (Localisation) clé
|
||||
string Nom; // (Nom)
|
||||
float Population;
|
||||
float Area; // (Superficie)
|
||||
|
||||
public:
|
||||
void saisie(ifstream& s);
|
||||
void affichage();
|
||||
|
||||
string key() { return Region; };
|
||||
};
|
||||
31
TP7/TP7.sln
Normal file
31
TP7/TP7.sln
Normal 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}") = "TP7", "TP7.vcxproj", "{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}"
|
||||
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
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Debug|x64.Build.0 = Debug|x64
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Release|x64.ActiveCfg = Release|x64
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Release|x64.Build.0 = Release|x64
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1DAA954A-822E-4982-9997-CB2A7CB3DCBA}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A5FC08F6-9D92-4CEC-92B5-C8B24659798A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
147
TP7/TP7.vcxproj
Normal file
147
TP7/TP7.vcxproj
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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>{1daa954a-822e-4982-9997-cb2a7cb3dcba}</ProjectGuid>
|
||||
<RootNamespace>TP7</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="Entreprise.cpp" />
|
||||
<ClCompile Include="getio.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Pays.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="countries.txt" />
|
||||
<Text Include="entreprises.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Entreprise.h" />
|
||||
<ClInclude Include="getio.h" />
|
||||
<ClInclude Include="Pays.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
50
TP7/TP7.vcxproj.filters
Normal file
50
TP7/TP7.vcxproj.filters
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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>
|
||||
<ClCompile Include="Entreprise.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Pays.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="getio.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="countries.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="entreprises.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Entreprise.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="getio.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Pays.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP7/TP7.vcxproj.user
Normal file
4
TP7/TP7.vcxproj.user
Normal 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>
|
||||
227
TP7/countries.txt
Normal file
227
TP7/countries.txt
Normal file
@@ -0,0 +1,227 @@
|
||||
ASIA (EX. NEAR EAST);Afghanistan;31056997;6475
|
||||
EASTERN EUROPE;Albania;3581655;28748
|
||||
NORTHERN AFRICA;Algeria;32930091;2381740
|
||||
OCEANIA;American Samoa;57794;199
|
||||
WESTERN EUROPE;Andorra;71201;468
|
||||
SUB-SAHARAN AFRICA;Angola;12127071;1246700
|
||||
LATIN AMER. & CARIB;Anguilla;13477;102
|
||||
LATIN AMER. & CARIB;Antigua & Barbuda;69108;443
|
||||
LATIN AMER. & CARIB;Argentina;39921833;2766890
|
||||
C.W. OF IND. STATES;Armenia;2976372;29800
|
||||
LATIN AMER. & CARIB;Aruba;71891;193
|
||||
OCEANIA;Australia;20264082;7686850
|
||||
WESTERN EUROPE;Austria;8192880;83870
|
||||
C.W. OF IND. STATES;Azerbaijan;7961619;86600
|
||||
LATIN AMER. & CARIB;Bahamas, The;303770;13940
|
||||
NEAR EAST;Bahrain;698585;665
|
||||
ASIA (EX. NEAR EAST);Bangladesh;147365352;144000
|
||||
LATIN AMER. & CARIB;Barbados;279912;431
|
||||
C.W. OF IND. STATES;Belarus;10293011;207600
|
||||
WESTERN EUROPE;Belgium;10379067;30528
|
||||
LATIN AMER. & CARIB;Belize;287730;22966
|
||||
SUB-SAHARAN AFRICA;Benin;7862944;112620
|
||||
NORTHERN AMERICA;Bermuda;65773;53
|
||||
ASIA (EX. NEAR EAST);Bhutan;2279723;47000
|
||||
LATIN AMER. & CARIB;Bolivia;8989046;1098580
|
||||
EASTERN EUROPE;Bosnia & Herzegovina;4498976;51129
|
||||
SUB-SAHARAN AFRICA;Botswana;1639833;600370
|
||||
LATIN AMER. & CARIB;Brazil;188078227;8511965
|
||||
LATIN AMER. & CARIB;British Virgin Is.;23098;153
|
||||
ASIA (EX. NEAR EAST);Brunei;379444;5770
|
||||
EASTERN EUROPE;Bulgaria;7385367;110910
|
||||
SUB-SAHARAN AFRICA;Burkina Faso;13902972;274200
|
||||
ASIA (EX. NEAR EAST);Burma;47382633;678500
|
||||
SUB-SAHARAN AFRICA;Burundi;8090068;27830
|
||||
ASIA (EX. NEAR EAST);Cambodia;13881427;181040
|
||||
SUB-SAHARAN AFRICA;Cameroon;17340702;475440
|
||||
NORTHERN AMERICA;Canada;33098932;9984670
|
||||
SUB-SAHARAN AFRICA;Cape Verde;420979;4033
|
||||
LATIN AMER. & CARIB;Cayman Islands;45436;262
|
||||
SUB-SAHARAN AFRICA;Central African Rep.;4303356;622984
|
||||
SUB-SAHARAN AFRICA;Chad;9944201;1284000
|
||||
LATIN AMER. & CARIB;Chile;16134219;756950
|
||||
ASIA (EX. NEAR EAST);China;1313973713;9596960
|
||||
LATIN AMER. & CARIB;Colombia;43593035;1138910
|
||||
SUB-SAHARAN AFRICA;Comoros;690948;2170
|
||||
SUB-SAHARAN AFRICA;Congo, Dem. Rep.;62660551;2345410
|
||||
SUB-SAHARAN AFRICA;Congo, Repub. of the;3702314;342000
|
||||
OCEANIA;Cook Islands;21388;240
|
||||
LATIN AMER. & CARIB;Costa Rica;4075261;51100
|
||||
SUB-SAHARAN AFRICA;Cote d'Ivoire;17654843;322460
|
||||
EASTERN EUROPE;Croatia;4494749;56542
|
||||
LATIN AMER. & CARIB;Cuba;11382820;110860
|
||||
NEAR EAST;Cyprus;784301;9250
|
||||
EASTERN EUROPE;Czech Republic;10235455;78866
|
||||
WESTERN EUROPE;Denmark;5450661;43094
|
||||
SUB-SAHARAN AFRICA;Djibouti;486530;23000
|
||||
LATIN AMER. & CARIB;Dominica;68910;754
|
||||
LATIN AMER. & CARIB;Dominican Republic;9183984;48730
|
||||
ASIA (EX. NEAR EAST);East Timor;1062777;15007
|
||||
LATIN AMER. & CARIB;Ecuador;13547510;283560
|
||||
NORTHERN AFRICA;Egypt;78887007;1001450
|
||||
LATIN AMER. & CARIB;El Salvador;6822378;21040
|
||||
SUB-SAHARAN AFRICA;Equatorial Guinea;540109;28051
|
||||
SUB-SAHARAN AFRICA;Eritrea;4786994;121320
|
||||
BALTICS;Estonia;1324333;45226
|
||||
SUB-SAHARAN AFRICA;Ethiopia;74777981;1127127
|
||||
WESTERN EUROPE;Faroe Islands;47246;1399
|
||||
OCEANIA;Fiji;905949;18270
|
||||
WESTERN EUROPE;Finland;5231372;338145
|
||||
WESTERN EUROPE;France;60876136;547030
|
||||
LATIN AMER. & CARIB;French Guiana;199509;91000
|
||||
OCEANIA;French Polynesia;274578;4167
|
||||
SUB-SAHARAN AFRICA;Gabon;1424906;267667
|
||||
SUB-SAHARAN AFRICA;Gambia, The;1641564;11300
|
||||
NEAR EAST;Gaza Strip;1428757;360
|
||||
C.W. OF IND. STATES;Georgia;4661473;69700
|
||||
WESTERN EUROPE;Germany;82422299;357021
|
||||
SUB-SAHARAN AFRICA;Ghana;22409572;239460
|
||||
WESTERN EUROPE;Gibraltar;27928;7
|
||||
WESTERN EUROPE;Greece;10688058;131940
|
||||
NORTHERN AMERICA;Greenland;56361;2166086
|
||||
LATIN AMER. & CARIB;Grenada;89703;344
|
||||
LATIN AMER. & CARIB;Guadeloupe;452776;1780
|
||||
OCEANIA;Guam;171019;541
|
||||
LATIN AMER. & CARIB;Guatemala;12293545;108890
|
||||
WESTERN EUROPE;Guernsey;65409;78
|
||||
SUB-SAHARAN AFRICA;Guinea;9690222;245857
|
||||
SUB-SAHARAN AFRICA;Guinea-Bissau;1442029;36120
|
||||
LATIN AMER. & CARIB;Guyana;767245;214970
|
||||
LATIN AMER. & CARIB;Haiti;8308504;27750
|
||||
LATIN AMER. & CARIB;Honduras;7326496;112090
|
||||
ASIA (EX. NEAR EAST);Hong Kong;6940432;1092
|
||||
EASTERN EUROPE;Hungary;9981334;93030
|
||||
WESTERN EUROPE;Iceland;299388;103000
|
||||
ASIA (EX. NEAR EAST);India;1095351995;3287590
|
||||
ASIA (EX. NEAR EAST);Indonesia;245452739;1919440
|
||||
ASIA (EX. NEAR EAST);Iran;68688433;1648000
|
||||
NEAR EAST;Iraq;26783383;437072
|
||||
WESTERN EUROPE;Ireland;4062235;70280
|
||||
WESTERN EUROPE;Isle of Man;75441;572
|
||||
NEAR EAST;Israel;6352117;20770
|
||||
WESTERN EUROPE;Italy;58133509;301230
|
||||
LATIN AMER. & CARIB;Jamaica;2758124;10991
|
||||
ASIA (EX. NEAR EAST);Japan;127463611;377835
|
||||
WESTERN EUROPE;Jersey;91084;116
|
||||
NEAR EAST;Jordan;5906760;92300
|
||||
C.W. OF IND. STATES;Kazakhstan;15233244;2717300
|
||||
SUB-SAHARAN AFRICA;Kenya;34707817;582650
|
||||
OCEANIA;Kiribati;105432;811
|
||||
ASIA (EX. NEAR EAST);Korea, North;23113019;120540
|
||||
ASIA (EX. NEAR EAST);Korea, South;48846823;98480
|
||||
NEAR EAST;Kuwait;2418393;17820
|
||||
C.W. OF IND. STATES;Kyrgyzstan;5213898;198500
|
||||
ASIA (EX. NEAR EAST);Laos;6368481;236800
|
||||
BALTICS;Latvia;2274735;64589
|
||||
NEAR EAST;Lebanon;3874050;10400
|
||||
SUB-SAHARAN AFRICA;Lesotho;2022331;30355
|
||||
SUB-SAHARAN AFRICA;Liberia;3042004;111370
|
||||
NORTHERN AFRICA;Libya;5900754;1759540
|
||||
WESTERN EUROPE;Liechtenstein;33987;160
|
||||
BALTICS;Lithuania;3585906;65200
|
||||
WESTERN EUROPE;Luxembourg;474413;2586
|
||||
ASIA (EX. NEAR EAST);Macau;453125;28
|
||||
EASTERN EUROPE;Macedonia;2050554;25333
|
||||
SUB-SAHARAN AFRICA;Madagascar;18595469;587040
|
||||
SUB-SAHARAN AFRICA;Malawi;13013926;118480
|
||||
ASIA (EX. NEAR EAST);Malaysia;24385858;329750
|
||||
ASIA (EX. NEAR EAST);Maldives;359008;300
|
||||
SUB-SAHARAN AFRICA;Mali;11716829;1240000
|
||||
WESTERN EUROPE;Malta;400214;316
|
||||
OCEANIA;Marshall Islands;60422;11854
|
||||
LATIN AMER. & CARIB;Martinique;436131;1100
|
||||
SUB-SAHARAN AFRICA;Mauritania;3177388;1030700
|
||||
SUB-SAHARAN AFRICA;Mauritius;1240827;2040
|
||||
SUB-SAHARAN AFRICA;Mayotte;201234;374
|
||||
LATIN AMER. & CARIB;Mexico;107449525;1972550
|
||||
OCEANIA;Micronesia, Fed. St.;108004;702
|
||||
C.W. OF IND. STATES;Moldova;4466706;33843
|
||||
WESTERN EUROPE;Monaco;32543;2
|
||||
ASIA (EX. NEAR EAST);Mongolia;2832224;1564116
|
||||
LATIN AMER. & CARIB;Montserrat;9439;102
|
||||
NORTHERN AFRICA;Morocco;33241259;446550
|
||||
SUB-SAHARAN AFRICA;Mozambique;19686505;801590
|
||||
SUB-SAHARAN AFRICA;Namibia;2044147;825418
|
||||
OCEANIA;Nauru;13287;21
|
||||
ASIA (EX. NEAR EAST);Nepal;28287147;147181
|
||||
WESTERN EUROPE;Netherlands;16491461;41526
|
||||
LATIN AMER. & CARIB;Netherlands Antilles;221736;960
|
||||
OCEANIA;New Caledonia;219246;19060
|
||||
OCEANIA;New Zealand;4076140;268680
|
||||
LATIN AMER. & CARIB;Nicaragua;5570129;129494
|
||||
SUB-SAHARAN AFRICA;Niger;12525094;1267000
|
||||
SUB-SAHARAN AFRICA;Nigeria;131859731;923768
|
||||
OCEANIA;N. Mariana Islands;82459;477
|
||||
WESTERN EUROPE;Norway;4610820;323802
|
||||
NEAR EAST;Oman;3102229;212460
|
||||
ASIA (EX. NEAR EAST);Pakistan;165803560;803940
|
||||
OCEANIA;Palau;20579;458
|
||||
LATIN AMER. & CARIB;Panama;3191319;78200
|
||||
OCEANIA;Papua New Guinea;5670544;462840
|
||||
LATIN AMER. & CARIB;Paraguay;6506464;406750
|
||||
LATIN AMER. & CARIB;Peru;28302603;1285220
|
||||
ASIA (EX. NEAR EAST);Philippines;89468677;300000
|
||||
EASTERN EUROPE;Poland;38536869;312685
|
||||
WESTERN EUROPE;Portugal;10605870;92391
|
||||
LATIN AMER. & CARIB;Puerto Rico;3927188;13790
|
||||
NEAR EAST;Qatar;885359;11437
|
||||
SUB-SAHARAN AFRICA;Reunion;787584;2517
|
||||
EASTERN EUROPE;Romania;22303552;237500
|
||||
C.W. OF IND. STATES;Russia;142893540;17075200
|
||||
SUB-SAHARAN AFRICA;Rwanda;8648248;26338
|
||||
SUB-SAHARAN AFRICA;Saint Helena;7502;413
|
||||
LATIN AMER. & CARIB;Saint Kitts & Nevis;39129;261
|
||||
LATIN AMER. & CARIB;Saint Lucia;168458;616
|
||||
NORTHERN AMERICA;St Pierre & Miquelon;7026;242
|
||||
LATIN AMER. & CARIB;Saint Vincent and the Grenadines;117848;389
|
||||
OCEANIA;Samoa;176908;2944
|
||||
WESTERN EUROPE;San Marino;29251;61
|
||||
SUB-SAHARAN AFRICA;Sao Tome & Principe;193413;1001
|
||||
NEAR EAST;Saudi Arabia;27019731;1960582
|
||||
SUB-SAHARAN AFRICA;Senegal;11987121;196190
|
||||
EASTERN EUROPE;Serbia;9396411;88361
|
||||
SUB-SAHARAN AFRICA;Seychelles;81541;455
|
||||
SUB-SAHARAN AFRICA;Sierra Leone;6005250;71740
|
||||
ASIA (EX. NEAR EAST);Singapore;4492150;693
|
||||
EASTERN EUROPE;Slovakia;5439448;48845
|
||||
EASTERN EUROPE;Slovenia;2010347;20273
|
||||
NORTHERN AMERICA;Solomon Islands;552438;28450
|
||||
SUB-SAHARAN AFRICA;Somalia;8863338;637657
|
||||
SUB-SAHARAN AFRICA;South Africa;44187637;1219912
|
||||
WESTERN EUROPE;Spain;40397842;504782
|
||||
ASIA (EX. NEAR EAST);Sri Lanka;20222240;65610
|
||||
SUB-SAHARAN AFRICA;Sudan;41236378;2505810
|
||||
LATIN AMER. & CARIB;Suriname;439117;163270
|
||||
SUB-SAHARAN AFRICA;Swaziland;1136334;17363
|
||||
WESTERN EUROPE;Sweden;9016596;449964
|
||||
WESTERN EUROPE;Switzerland;7523934;41290
|
||||
NEAR EAST;Syria;18881361;185180
|
||||
ASIA (EX. NEAR EAST);Taiwan;23036087;35980
|
||||
C.W. OF IND. STATES;Tajikistan;7320815;143100
|
||||
SUB-SAHARAN AFRICA;Tanzania;37445392;945087
|
||||
ASIA (EX. NEAR EAST);Thailand;64631595;514000
|
||||
SUB-SAHARAN AFRICA;Togo;5548702;56785
|
||||
OCEANIA;Tonga;114689;748
|
||||
LATIN AMER. & CARIB;Trinidad & Tobago;1065842;5128
|
||||
NORTHERN AFRICA;Tunisia;10175014;163610
|
||||
NEAR EAST;Turkey;70413958;780580
|
||||
C.W. OF IND. STATES;Turkmenistan;5042920;488100
|
||||
LATIN AMER. & CARIB;Turks & Caicos Is;21152;430
|
||||
OCEANIA;Tuvalu;11810;26
|
||||
SUB-SAHARAN AFRICA;Uganda;28195754;236040
|
||||
C.W. OF IND. STATES;Ukraine;46710816;603700
|
||||
NEAR EAST;United Arab Emirates;2602713;82880
|
||||
WESTERN EUROPE;UK;60609153;244820
|
||||
NORTHERN AMERICA;US;298444215;9631420
|
||||
LATIN AMER. & CARIB;Uruguay;3431932;176220
|
||||
C.W. OF IND. STATES;Uzbekistan;27307134;447400
|
||||
OCEANIA;Vanuatu;208869;12200
|
||||
LATIN AMER. & CARIB;Venezuela;25730435;912050
|
||||
ASIA (EX. NEAR EAST);Vietnam;84402966;329560
|
||||
LATIN AMER. & CARIB;Virgin Islands;108605;1910
|
||||
OCEANIA;Wallis and Futuna;16025;274
|
||||
NEAR EAST;West Bank;2460492;5860
|
||||
NORTHERN AFRICA;Western Sahara;273008;266000
|
||||
NEAR EAST;Yemen;21456188;527970
|
||||
SUB-SAHARAN AFRICA;Zambia;11502010;752614
|
||||
SUB-SAHARAN AFRICA;Zimbabwe;12236805;390580
|
||||
150
TP7/entreprises.txt
Normal file
150
TP7/entreprises.txt
Normal file
@@ -0,0 +1,150 @@
|
||||
Apple;US;724773.10;Technology hardware & equipment;182795.00;92600.00;1;1
|
||||
Exxon Mobil;US;356548.70;Oil & gas producers;364763.00;75300.00;2;2
|
||||
Berkshire Hathaway;US;356510.70;Nonlife insurance;0.00;316000.00;3;5
|
||||
Google;US;345849.20;Software & computer services;66001.00;53600.00;4;4
|
||||
Microsoft;US;333524.80;Software & computer services;868.33;128000.00;5;3
|
||||
PetroChina;China;329715.10;Oil & gas producers;367853.70;534652.00;6;16
|
||||
Wells Fargo;US;279919.70;Banks;0.00;264500.00;7;7
|
||||
Johnson & Johnson;US;279723.90;Pharmaceuticals & biotechnology;74331.00;126500.00;8;6
|
||||
Industrial & Commercial Bank of China;China;275389.10;Banks;0.00;462282.00;9;21
|
||||
Novartis;Switzerland;267897.00;Pharmaceuticals & biotechnology;49550.70;133413.00;10;14
|
||||
China Mobile;Hong Kong;267252.30;Mobile telecommunications;103977.00;241550.00;11;25
|
||||
Wal-Mart Stores;US;265107.30;General retailers;485651.00;2200000.00;12;10
|
||||
General Electric;US;249774.40;General industrials;148589.00;305000.00;13;8
|
||||
Nestle;Switzerland;243701.80;Food producers;92165.30;339000.00;14;11
|
||||
Toyota Motor;Japan;238924.80;Automobiles & parts;248954.60;338875.00;15;23
|
||||
Roche;Switzerland;237747.60;Pharmaceuticals & biotechnology;47748.70;88509.00;16;9
|
||||
JP Morgan Chase;US;225861.10;Banks;0.00;241359.00;17;13
|
||||
Procter & Gamble;US;221279.60;Household goods & home construction;83062.00;118000.00;18;17
|
||||
Samsung Electronics;South Korea;214039.70;Leisure goods;188475.90;99927.00;19;18
|
||||
Pfizer;US;213621.90;Pharmaceuticals & biotechnology;49605.00;78300.00;20;19
|
||||
China Construction Bank;China;209139.80;Banks;0.00;493583.00;21;29
|
||||
Verizon Communications;US;198035.30;Fixed line telecommunications;127079.00;177300.00;22;22
|
||||
Chevron;US;197381.30;Oil & gas producers;191755.00;64700.00;23;15
|
||||
Bank of China;China;197225.60;Banks;0.00;308128.00;24;52
|
||||
Anheuser-Busch InBev;Belgium;196554.30;Beverages;43098.80;154029.00;25;32
|
||||
Royal Dutch Shell;UK;192134.90;Oil & gas producers;385634.50;94000.00;26;12
|
||||
Agricultural Bank of China;China;189297.40;Banks;0.00;493583.00;27;38
|
||||
Oracle;US;188438.80;Software & computer services;38275.00;122000.00;28;27
|
||||
Facebook;US;183860.10;Software & computer services;12466.00;9199.00;29;49
|
||||
Walt Disney;US;178267.10;Media;48813.00;180000.00;30;39
|
||||
Tencent;Hong Kong;177960.60;Software & computer services;12718.30;27690.00;31;42
|
||||
Coca-Cola;US;177142.30;Beverages;46052.00;129200.00;32;31
|
||||
Amazon.com;US;172797.30;General retailers;88988.00;154100.00;33;35
|
||||
AT&T;US;169458.80;Fixed line telecommunications;132447.00;253000.00;34;26
|
||||
HSBC;UK;164249.60;Banks;0.00;257603.00;35;24
|
||||
Merck;US;163139.30;Pharmaceuticals & biotechnology;42237.00;70000.00;36;33
|
||||
Bank of America;US;161908.80;Banks;0.00;224000.00;37;28
|
||||
IBM;US;158642.00;Software & computer services;92793.00;379592.00;38;20
|
||||
China Life Insurance;China;157029.70;Life insurance;0.00;103123.00;39;131
|
||||
Citigroup;US;156359.80;Banks;0.00;241000.00;40;37
|
||||
Home Depot;US;148533.10;General retailers;83176.00;371000.00;41;59
|
||||
Intel;US;148094.70;Technology hardware & equipment;55870.00;106700.00;42;46
|
||||
Gilead Sciences;US;145532.90;Pharmaceuticals & biotechnology;24890.00;7000.00;43;60
|
||||
Comcast;US;142798.50;Media;68775.00;139000.00;44;44
|
||||
PepsiCo;US;141742.70;Beverages;66683.00;271000.00;45;47
|
||||
Cisco Systems;US;140507.80;Technology hardware & equipment;47142.00;74042.00;46;56
|
||||
Sanofi;France;130260.00;Pharmaceuticals & biotechnology;41244.30;113496.00;47;40
|
||||
Visa;US;128455.30;Financial services;0.00;7000.00;48;61
|
||||
Volkswagen;Germany;124335.30;Automobiles & parts;244810.20;592586.00;49;50
|
||||
Bayer;Germany;124157.70;Chemicals;51075.00;118888.00;50;57
|
||||
BHP Billiton;Australia/UK;122335.40;Mining;69372.10;47044.00;51;30
|
||||
Amgen;US;121303.90;Pharmaceuticals & biotechnology;20063.00;17900.00;52;80
|
||||
Taiwan Semiconductor Manufacturing;Taiwan;120577.10;Technology hardware & equipment;24112.30;43591.00;53;67
|
||||
Actavis;US;120536.10;Pharmaceuticals & biotechnology;13062.30;21600.00;54;285
|
||||
Sinopec;China;119104.80;Oil & gas producers;433310.20;358571.00;55;74
|
||||
Unilever;Netherlands/UK;118902.50;Personal goods;58568.30;173000.00;56;51
|
||||
Total;France;118541.90;Oil & gas producers;194159.30;100307.00;57;34
|
||||
BP;UK;118345.60;Oil & gas producers;334605.90;84500.00;58;36
|
||||
CVS Caremark;US;117170.80;Food & drug retailers;139367.00;217800.00;59;88
|
||||
Philip Morris International;US;116693.10;Tobacco;29767.00;82500.00;60;43
|
||||
Commonwealth Bank of Australia;Australia;115688.20;Banks;0.00;44329.00;61;55
|
||||
Qualcomm;US;114380.50;Technology hardware & equipment;26487.00;31300.00;62;41
|
||||
Ping An Insurance;China;113119.00;Life insurance;0.00;235999.00;63;172
|
||||
Novo Nordisk;Denmark;112977.60;Pharmaceuticals & biotechnology;14428.30;40957.00;64;68
|
||||
UnitedHealth Group;US;112812.60;Health care equipment & services;130474.00;170000.00;65;100
|
||||
GlaxoSmithKline;UK;111649.60;Pharmaceuticals & biotechnology;35834.80;98702.00;66;45
|
||||
Medtronic;US;111140.90;Health care equipment & services;17005.00;49000.00;67;144
|
||||
Bristol Myers Squibb;US;107500.10;Pharmaceuticals & biotechnology;15879.00;25000.00;68;93
|
||||
Schlumberger;US;106628.40;Oil equipment & services;48631.00;120000.00;69;48
|
||||
United Technologies;US;106470.30;Aerospace & defence;65100.00;211000.00;70;62
|
||||
Banco Santander;Spain;105960.30;Banks;0.00;185405.00;71;58
|
||||
Boeing;US;105032.20;Aerospace & defence;90762.00;165500.00;72;81
|
||||
3M;US;104795.40;General industrials;31821.00;89800.00;73;87
|
||||
Daimler;Germany;103741.00;Automobiles & parts;157039.90;279972.00;74;66
|
||||
L'Oreal;France;103279.40;Personal goods;27245.50;78611.00;75;71
|
||||
Inditex;Spain;100013.20;General retailers;22539.10;128313.00;76;79
|
||||
Biogen Idec;US;99063.50;Pharmaceuticals & biotechnology;9703.30;7550.00;77;115
|
||||
Altria Group;US;98505.20;Tobacco;17945.00;9000.00;78;109
|
||||
British American Tobacco;UK;96536.70;Tobacco;21761.70;90118.00;79;63
|
||||
Mastercard;US;96001.80;Financial services;0.00;10300.00;80;95
|
||||
Union Pacific;US;95451.80;Industrial transportation;23988.00;47201.00;81;94
|
||||
Westpac Banking;Australia;93870.40;Banks;0.00;36373.00;82;70
|
||||
McDonald's;US;93651.40;Travel & leisure;27441.30;420000.00;83;73
|
||||
Abbvie;US;93204.10;Pharmaceuticals & biotechnology;19960.00;26000.00;84;97
|
||||
Walgreen;US;92298.90;Food & drug retailers;76392.00;251000.00;85;138
|
||||
Celgene;US;92292.00;Pharmaceuticals & biotechnology;7670.40;6012.00;86;166
|
||||
Basf;Germany;91489.50;Chemicals;89874.30;113292.00;87;65
|
||||
Ambev;Brazil;90732.60;Beverages;14326.40;51871.00;88;54
|
||||
Kinder Morgan;US;90622.50;Oil equipment & services;16190.00;11535.00;89;314
|
||||
Siemens;Germany;90196.50;General industrials;90808.40;343000.00;90;53
|
||||
LVMH;France;89497.40;Personal goods;37047.20;121289.00;91;82
|
||||
SAP;Germany;88793.30;Software & computer services;21233.40;74406.00;92;69
|
||||
Mitsubishi UFJ Financial;Japan;87866.40;Banks;0.00;106141.00;93;104
|
||||
Royal Bank Canada;Canada;86842.80;Banks;0.00;78000.00;94;77
|
||||
AstraZeneca;UK;86763.10;Pharmaceuticals & biotechnology;24695.50;57500.00;95;98
|
||||
Vodafone Group;UK;86760.20;Mobile telecommunications;63910.10;92812.00;96;72
|
||||
SabMiller;UK;84939.60;Beverages;17430.10;69947.00;97;101
|
||||
Deutsche Telekom;Germany;83314.00;Mobile telecommunications;75765.40;227811.00;98;116
|
||||
Lloyds Banking Group;UK;82941.00;Banks;0.00;84490.00;99;89
|
||||
Goldman Sachs;US;81883.60;Financial services;0.00;34000.00;100;110
|
||||
Honeywell International;US;81427.30;General industrials;40306.00;127000.00;101;113
|
||||
Eli Lilly;US;80714.40;Pharmaceuticals & biotechnology;19615.60;39135.00;102;132
|
||||
BMW;Germany;80263.30;Automobiles & parts;97220.10;116324.00;103;99
|
||||
Tata Consultancy Services;India;79935.90;Software & computer services;13629.40;300464.00;104;125
|
||||
American Express;US;79617.90;Financial services;0.00;54000.00;105;76
|
||||
Allianz;Germany;79417.80;Nonlife insurance;0.00;147425.00;106;106
|
||||
Toronto-Dominion Bank;Canada;79165.70;Banks;0.00;81137.00;107;91
|
||||
US Bancorp;US;77784.50;Banks;0.00;66750.00;108;103
|
||||
ANZ Banking;Australia;77424.40;Banks;0.00;50328.00;109;96
|
||||
Rio Tinto;Australia/UK;77074.50;Mining;45107.70;59775.00;110;64
|
||||
ConocoPhillips;US;76670.70;Oil & gas producers;52464.00;19100.00;111;92
|
||||
AIA Group;Hong Kong;75815.80;Life insurance;0.00;20000.00;112;165
|
||||
BNP Paribas;France;75696.80;Banks;0.00;187903.00;113;75
|
||||
American International Group;US;74183.90;Nonlife insurance;0.00;65000.00;114;114
|
||||
Lowe's Companies;US;71414.30;General retailers;56223.00;266000.00;115;199
|
||||
National Australia Bank;Australia;71303.90;Banks;0.00;42853.00;116;107
|
||||
Twenty-First Century Fox;US;71181.80;Media;31867.00;27000.00;117;120
|
||||
NTT DoCoMo;Japan;71051.70;Mobile telecommunications;43229.10;23890.00;118;127
|
||||
Starbucks;US;71006.00;Travel & leisure;16447.80;191000.00;119;170
|
||||
Morgan Stanley;US;70545.30;Financial services;0.00;55802.00;120;146
|
||||
UBS;Switzerland;70519.70;Banks;0.00;60155.00;121;102
|
||||
Bank of Communications;China;70487.00;Banks;0.00;93658.00;122;210
|
||||
Telefonica;Spain;70326.60;Fixed line telecommunications;60915.40;123700.00;123;117
|
||||
Time Warner;US;70129.30;Media;27359.00;25600.00;124;162
|
||||
Nippon Telegraph & Telephone;Japan;70111.70;Fixed line telecommunications;105864.90;239756.00;125;143
|
||||
eBay;US;69945.60;General retailers;17902.00;34600.00;126;119
|
||||
Abbott Laboratories;US;69910.90;Pharmaceuticals & biotechnology;20247.00;77000.00;127;157
|
||||
Softbank;Japan;69882.10;Mobile telecommunications;64599.90;70336.00;128;85
|
||||
Diageo;UK;69404.90;Beverages;17535.00;26588.00;129;105
|
||||
Nike;US;68620.70;Personal goods;27799.00;56500.00;130;182
|
||||
United Parcel Service;US;68085.10;Industrial transportation;58232.00;270000.00;131;126
|
||||
Valeant Pharmaceuticals International;Canada;67339.00;Pharmaceuticals & biotechnology;7878.50;16800.00;132;226
|
||||
Costco Wholesale;US;66653.90;General retailers;112640.00;195000.00;133;201
|
||||
E I Du Pont de Nemours;US;64709.90;Chemicals;34906.00;63000.00;134;145
|
||||
Naspers;South Africa;64697.60;Media;5955.40;22557.00;135;215
|
||||
Lockheed Martin;US;64192.50;Aerospace & defence;45600.00;112000.00;136;183
|
||||
Saudi Basic Industries;Saudi Arabia;63940.80;Chemicals;50138.40;40000.00;137;78
|
||||
BBVA;Spain;63794.00;Banks;0.00;109239.00;138;121
|
||||
Prudential;UK;63738.00;Life insurance;0.00;23047.00;139;175
|
||||
Japan Tobacco;Japan;63381.30;Tobacco;23980.80;51341.00;140;139
|
||||
Express Scripts;US;63237.30;Health care equipment & services;100887.10;29500.00;141;163
|
||||
CNOOC;Hong Kong;63115.30;Oil & gas producers;44517.40;21046.00;142;129
|
||||
China Merchants Bank;China;63023.80;Banks;0.00;75109.00;143;245
|
||||
Ford Motor;US;63010.70;Automobiles & parts;144077.00;187000.00;144;148
|
||||
Eni;Italy;62954.90;Oil & gas producers;132825.90;84405.00;145;84
|
||||
Colgate-Palmolive;US;62880.00;Personal goods;17277.00;37700.00;146;156
|
||||
China Shenhua Energy;China;62119.20;Mining;40018.30;92738.00;147;212
|
||||
Reckitt Benckiser;UK;61656.40;Household goods & home construction;13763.20;37200.00;148;160
|
||||
Axa;France;61520.40;Nonlife insurance;0.00;96279.00;149;140
|
||||
Simon Property Group;US;61493.90;Real estate investment trusts;0.00;5250.00;150;187
|
||||
47
TP7/getio.cpp
Normal file
47
TP7/getio.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "getio.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void getfloat(ifstream& s, float& f, const char sep) {
|
||||
s >> f;
|
||||
s.ignore();
|
||||
}
|
||||
|
||||
void getint(ifstream& s, int& f, const char sep) {
|
||||
s >> f;
|
||||
s.ignore();
|
||||
}
|
||||
|
||||
/*void getfloat(ifstream& s, float& f, const char sep) {
|
||||
string tmp;
|
||||
|
||||
getline(s, tmp, sep);
|
||||
|
||||
if (tmp == "N/R" || tmp.empty())
|
||||
return;
|
||||
|
||||
tmp.erase(remove(tmp.begin(), tmp.end(), '.'), tmp.end());
|
||||
|
||||
auto it = tmp.begin();
|
||||
while (it != tmp.end() && *it != ',')
|
||||
it++;
|
||||
if (it != tmp.end()) {
|
||||
*it = '.';
|
||||
}
|
||||
|
||||
f = stof(tmp);
|
||||
}*/
|
||||
|
||||
/*void getint(ifstream& s, int& f, const char sep) {
|
||||
string tmp;
|
||||
|
||||
getline(s, tmp, sep);
|
||||
|
||||
if (tmp == "N/R" || tmp.empty())
|
||||
return;
|
||||
|
||||
f = stoi(tmp);
|
||||
}*/
|
||||
21
TP7/getio.h
Normal file
21
TP7/getio.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void getfloat(ifstream& s, float& f, const char sep);
|
||||
void getint(ifstream& s, int& f, const char sep);
|
||||
|
||||
template <class T>
|
||||
void format(T t, int w) {
|
||||
cout << left << setw(w) << t << " ";
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void format(T t) {
|
||||
format(t, 4);
|
||||
}
|
||||
200
TP7/main.cpp
Normal file
200
TP7/main.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "Entreprise.h"
|
||||
#include "Pays.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class M>
|
||||
void lire(M& map, const string filename) {
|
||||
using V = typename M::mapped_type;
|
||||
using K = typename M::key_type;
|
||||
|
||||
ifstream f(filename);
|
||||
|
||||
if (!f.is_open()) {
|
||||
cout << "Erreur lors de la lecture du fichier " << filename << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//f.ignore(200, '\n');
|
||||
while (!f.eof()) {
|
||||
V a;
|
||||
a.saisie(f);
|
||||
|
||||
// a.affichage();
|
||||
// map[a.key()] = a;
|
||||
map.insert(make_pair(a.key(), a));
|
||||
|
||||
// f.ignore(2000, '\n');
|
||||
}
|
||||
}
|
||||
|
||||
template <class M>
|
||||
void affichage_el(M el) {
|
||||
el.affichage();
|
||||
}
|
||||
|
||||
void affichage_el(float el) {
|
||||
cout << el;
|
||||
}
|
||||
|
||||
template <class Start, class Stop>
|
||||
void affichage_range(Start start, Stop stop) {
|
||||
cout << left << setw(30) << "Key" << "Value\n";
|
||||
for (; start != stop; start++) {
|
||||
cout << left << setw(30) << start->first;
|
||||
affichage_el(start->second);
|
||||
cout << '\n';
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class M>
|
||||
void affichage(M& map) {
|
||||
affichage_range(map.begin(), map.end());
|
||||
}
|
||||
|
||||
void chercher(const map<string, Entreprise>& entreprises) {
|
||||
string r;
|
||||
|
||||
cout << "Entrez le nom de l'entreprise à rechercher : ";
|
||||
getline(cin, r);
|
||||
|
||||
auto it = entreprises.find(r);
|
||||
if (it == entreprises.end()) {
|
||||
cout << "L'entreprise n'a pas été trouvée" << endl;
|
||||
}
|
||||
else {
|
||||
cout << "Entreprise trouvée!" << endl;
|
||||
Entreprise e = it->second;
|
||||
e.affichage();
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool cmp_progression_classement(const pair<string, Entreprise>& e1, const pair<string, Entreprise>& e2) {
|
||||
return e1.second.rank_progress() < e2.second.rank_progress();
|
||||
}
|
||||
|
||||
void ranking_progress(const map<string, Entreprise>& entreprise) {
|
||||
auto it_max = max_element(entreprise.begin(), entreprise.end(), cmp_progression_classement);
|
||||
auto it_min = min_element(entreprise.begin(), entreprise.end(), cmp_progression_classement);
|
||||
|
||||
cout << "L'entreprise avec la plus grosse chute est " << it_min->first << " (" << it_min->second.rank_progress() << ")" << endl;
|
||||
cout << "L'entreprise avec la plus grosse progression est " << it_max->first << " (+" << it_max->second.rank_progress() << ")" << endl;
|
||||
}
|
||||
|
||||
bool cmp_ranking(const pair<string, float> &p1, const pair<string, float>& p2) {
|
||||
return p1.second > p2.second;
|
||||
}
|
||||
|
||||
bool cmp_turnover(const pair<string, Entreprise>& e1, const pair<string, Entreprise>& e2) {
|
||||
return e1.second.getTurnover() < e2.second.getTurnover();
|
||||
}
|
||||
|
||||
void entreprises_ranking(const map<string, Entreprise>& entreprises) {
|
||||
vector<pair<string, float>> ranking;
|
||||
|
||||
for (auto& e : entreprises) {
|
||||
float turnover = e.second.turnover_empl();
|
||||
ranking.push_back(make_pair(e.first, turnover));
|
||||
}
|
||||
|
||||
sort(ranking.begin(), ranking.end(), cmp_ranking);
|
||||
|
||||
affichage(ranking);
|
||||
|
||||
auto e_max = max_element(entreprises.begin(), entreprises.end(), cmp_turnover);
|
||||
cout << "Le turnover maximum est : " << e_max->second.getTurnover() << " pour l'entreprise " << e_max->first << endl;
|
||||
}
|
||||
|
||||
void toupper(string& s) {
|
||||
for (int i = 0; i < s.size(); i++)
|
||||
s[i] = toupper(s[i]);
|
||||
}
|
||||
|
||||
void pays_region( const multimap<string, Pays>& pays) {
|
||||
string recherche;
|
||||
|
||||
cout << "Entrez le nom de la région cherchée: ";
|
||||
getline(cin, recherche);
|
||||
toupper(recherche);
|
||||
|
||||
auto range = pays.equal_range(recherche);
|
||||
|
||||
if (range.first == pays.end()) {
|
||||
cout << "La région n'a pas été trouvée" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//for (auto it = range.first; it != range.second; it++) {
|
||||
affichage_range(range.first, range.second);
|
||||
//}
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int choix;
|
||||
|
||||
cout << "1. Lire le fichier Entreprises et affichage" << endl
|
||||
<< "2. Lire le fichier Pays et affichage" << endl
|
||||
<< "3. Chercher une entreprise par son nom et affichage" << endl
|
||||
<< "4. Cherchez les entreprises ayant réalisé la plus grosse progression / chute et affichage" << endl
|
||||
<< "5. Calculez le Turnover / Employee, le chiffre d’affaire moyen généré par employé, de toutes les entreprises, et trouver le max" << endl
|
||||
<< "6. Pour une région donnée, affichez tous les pays dans cette région" << endl
|
||||
<< "7. Quitter" << endl;
|
||||
|
||||
cout << "Votre choix : ";
|
||||
|
||||
cin >> choix; cin.ignore();
|
||||
return choix;
|
||||
}
|
||||
|
||||
int main() {
|
||||
map<string, Entreprise> entreprises;
|
||||
multimap<string, Pays> pays;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
lire(entreprises, "entreprises.txt");
|
||||
affichage(entreprises);
|
||||
break;
|
||||
case 2:
|
||||
lire(pays, "countries.txt");
|
||||
affichage(pays);
|
||||
break;
|
||||
case 3:
|
||||
chercher(entreprises);
|
||||
break;
|
||||
case 4:
|
||||
ranking_progress(entreprises);
|
||||
break;
|
||||
case 5:
|
||||
entreprises_ranking(entreprises);
|
||||
break;
|
||||
case 6:
|
||||
pays_region(pays);
|
||||
break;
|
||||
case 7:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
affichage(pays);
|
||||
|
||||
cout << entreprises.size() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ bool comparer_prix(T& a, T& b) {
|
||||
|
||||
template <class C>
|
||||
void plus_cher(C& cont) {
|
||||
// pour obtenir les bières LES + chers ont peu soit
|
||||
// pour obtenir les bières LES + chers on peut soit
|
||||
// itérer pour récupérer le max() en prix
|
||||
// puis réitéré et n'afficher que les bières ou
|
||||
// prix == max
|
||||
|
||||
31
TP8/COQ/COQ.sln
Normal file
31
TP8/COQ/COQ.sln
Normal 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}") = "COQ", "COQ.vcxproj", "{B01EA899-3FB4-4537-BC98-F70A30C56399}"
|
||||
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
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x64.Build.0 = Debug|x64
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x64.ActiveCfg = Release|x64
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x64.Build.0 = Release|x64
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CEFA4EB7-CAEA-4B51-B46C-5AAD3C89E542}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
135
TP8/COQ/COQ.vcxproj
Normal file
135
TP8/COQ/COQ.vcxproj
Normal 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>{b01ea899-3fb4-4537-bc98-f70a30c56399}</ProjectGuid>
|
||||
<RootNamespace>COQ</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>
|
||||
22
TP8/COQ/COQ.vcxproj.filters
Normal file
22
TP8/COQ/COQ.vcxproj.filters
Normal 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>
|
||||
4
TP8/COQ/COQ.vcxproj.user
Normal file
4
TP8/COQ/COQ.vcxproj.user
Normal 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>
|
||||
BIN
TP8/COQ/Côté_Coq_Poule.pdf
Normal file
BIN
TP8/COQ/Côté_Coq_Poule.pdf
Normal file
Binary file not shown.
245
TP8/COQ/main.cpp
Normal file
245
TP8/COQ/main.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Poule;
|
||||
class Oeuf;
|
||||
|
||||
template <class C>
|
||||
void affiche_cont(C& cont) {
|
||||
for (auto& volaille : cont) {
|
||||
volaille.affiche();
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
class Coq {
|
||||
string Nom;
|
||||
int Age;
|
||||
|
||||
public:
|
||||
void saisie();
|
||||
void affiche();
|
||||
|
||||
Oeuf Cocorico(Poule p);
|
||||
|
||||
bool operator<(Coq& c2) {
|
||||
return Age < c2.Age;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void CocoricoPoules(C&c) {
|
||||
vector<Oeuf> oeufs;
|
||||
oeufs.reserve(c.size());
|
||||
for (auto poule : c) {
|
||||
oeufs.push_back(Cocorico(poule));
|
||||
}
|
||||
affiche_cont(oeufs);
|
||||
}
|
||||
};
|
||||
|
||||
class Poule {
|
||||
string Nom;
|
||||
int Poids;
|
||||
|
||||
friend Coq;
|
||||
|
||||
protected:
|
||||
void set_poids(int poids) { Poids = poids; }
|
||||
|
||||
public:
|
||||
void saisie();
|
||||
void affiche();
|
||||
|
||||
float get_poids() {
|
||||
return Poids;
|
||||
}
|
||||
|
||||
bool operator<(Poule& c2) {
|
||||
return Poids < c2.Poids;
|
||||
}
|
||||
};
|
||||
|
||||
class Oeuf : public Poule {
|
||||
char Qualite;
|
||||
|
||||
public:
|
||||
Oeuf(int poids) {
|
||||
set_poids(poids);
|
||||
|
||||
cout << "L'oeuf a bien ete pondu et pese : "<<poids<<"(gr)" << endl;
|
||||
}
|
||||
|
||||
void saisie();
|
||||
void affiche();
|
||||
};
|
||||
|
||||
template <class C, class T>
|
||||
void saisie(C& cont, const string nom) {
|
||||
int n;
|
||||
|
||||
cout << "Combien de " << nom << " ? : ";
|
||||
cin >> n; cin.ignore();
|
||||
|
||||
while (n-- > 0) {
|
||||
T p;
|
||||
p.saisie();
|
||||
cont.insert(cont.begin(), p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int poids_poules(list<Poule> poules) {
|
||||
int S = 0;
|
||||
for (Poule& p : poules) {
|
||||
S += p.get_poids() / 1000;
|
||||
}
|
||||
return S;
|
||||
}
|
||||
|
||||
pair<Poule, Coq> couple(list<Poule> poules, vector<Coq> coqs) {
|
||||
auto poule = max_element(poules.begin(), poules.end());
|
||||
auto coq = min_element(coqs.begin(), coqs.end());
|
||||
|
||||
if (poule == poules.end() || coq == coqs.end()) {
|
||||
cout << "Aucun couple n'a pu être formé";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cout << "Le couple formé est ";
|
||||
coq->affiche();
|
||||
cout << " et ";
|
||||
poule->affiche();
|
||||
cout << endl;
|
||||
|
||||
return make_pair(*poule, *coq);
|
||||
}
|
||||
|
||||
Coq plus_vieux_coq(vector<Coq> coqs) {
|
||||
auto coq = max_element(coqs.begin(), coqs.end());
|
||||
if (coq == coqs.end()) {
|
||||
cout << "Il n'y a pas de coq!";
|
||||
exit(1);
|
||||
}
|
||||
return *coq;
|
||||
}
|
||||
|
||||
// Faut-il effacer l'unique élément si le conteneur ne contient qu'un seul élément ?
|
||||
// Supprimer la première moitié? que vaut la moitié pour 1 élement.
|
||||
template <class C>
|
||||
void effacer_moitie(C& c) {
|
||||
auto it = c.begin();
|
||||
for (int i = 0; i < c.size() / 2; i++) it++;
|
||||
|
||||
c.erase(c.begin(), it);
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
|
||||
cout << "1) Saisir_Clav 1 List de Poule(s) (insertion au début) + Affichage" << endl
|
||||
<< "2) Saisir_Clav 1 Vector de Coq(s) (insertion au début) + Affichage" << endl
|
||||
<< "3) Calculer et afficher la Somme des poids en Kg : Sp" << endl
|
||||
<< "4) Le plus jeune des Coqs épouse la Poule la plus lourde" << endl
|
||||
<< "5) Le Coq fait Cocorico et toutes les Poules pondent + Affichage" << endl
|
||||
<< "6) Effacer la première moitié de List et de Vector + Affichage" << endl
|
||||
<< "Votre choix : ";
|
||||
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
int main() {
|
||||
list<Poule> poules;
|
||||
vector<Coq> coqs;
|
||||
|
||||
float Sp;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
saisie<list<Poule>, Poule>(poules, "Poules");
|
||||
affiche_cont(poules);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
saisie<vector<Coq>, Coq>(coqs, "Coqs");
|
||||
affiche_cont(coqs);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Sp = poids_poules(poules);
|
||||
cout << "Somme de Poids des poules en Kg : " << Sp;
|
||||
|
||||
break;
|
||||
case 4:
|
||||
couple(poules, coqs);
|
||||
|
||||
break;
|
||||
|
||||
// Cocorico
|
||||
case 5:
|
||||
plus_vieux_coq(coqs).CocoricoPoules(poules);
|
||||
break;
|
||||
case 6:
|
||||
effacer_moitie(coqs);
|
||||
effacer_moitie(poules);
|
||||
|
||||
affiche_cont(coqs);
|
||||
affiche_cont(poules);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Poule::saisie() {
|
||||
cout << "Le nom ? : ";
|
||||
getline(cin, Nom);
|
||||
cout << "Le poids ? : ";
|
||||
cin >> Poids; cin.ignore();
|
||||
}
|
||||
|
||||
void Coq::saisie() {
|
||||
cout << "Le nom ? : ";
|
||||
getline(cin, Nom);
|
||||
cout << "L' age ? : ";
|
||||
cin >> Age; cin.ignore();
|
||||
}
|
||||
|
||||
void Poule::affiche() {
|
||||
cout << Nom << "(" << Poids << ") ";
|
||||
}
|
||||
|
||||
void Coq::affiche() {
|
||||
cout << Nom << "(" << Age << ") ";
|
||||
}
|
||||
|
||||
void Oeuf::affiche() {
|
||||
cout << Qualite << "(" << get_poids() << "gr)";
|
||||
}
|
||||
|
||||
void Oeuf::saisie() {
|
||||
cout << "Saisir qualité de l'oeuf (A, B ou C) ? : ";
|
||||
cin >> Qualite;
|
||||
}
|
||||
|
||||
Oeuf Coq::Cocorico(Poule p) {
|
||||
Oeuf oeuf(p.get_poids() / 10);
|
||||
|
||||
oeuf.saisie();
|
||||
|
||||
return oeuf;
|
||||
}
|
||||
BIN
TP8/EtudProf/Côté_Etud_Prof_VF.pdf
Normal file
BIN
TP8/EtudProf/Côté_Etud_Prof_VF.pdf
Normal file
Binary file not shown.
31
TP8/EtudProf/EtudProf.sln
Normal file
31
TP8/EtudProf/EtudProf.sln
Normal 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}") = "EtudProf", "EtudProf.vcxproj", "{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}"
|
||||
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
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Debug|x64.Build.0 = Debug|x64
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Debug|x86.Build.0 = Debug|Win32
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Release|x64.ActiveCfg = Release|x64
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Release|x64.Build.0 = Release|x64
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D6DEC2BC-4A3C-4AA0-BD88-5FE3113CF810}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2112B69A-D512-4F99-A3CE-CBDB944F07B8}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
139
TP8/EtudProf/EtudProf.vcxproj
Normal file
139
TP8/EtudProf/EtudProf.vcxproj
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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>{d6dec2bc-4a3c-4aa0-bd88-5fe3113cf810}</ProjectGuid>
|
||||
<RootNamespace>EtudProf</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>
|
||||
<ItemGroup>
|
||||
<Text Include="Etud_M.txt" />
|
||||
<Text Include="Prof_M.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
TP8/EtudProf/EtudProf.vcxproj.filters
Normal file
30
TP8/EtudProf/EtudProf.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<ItemGroup>
|
||||
<Text Include="Prof_M.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="Etud_M.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP8/EtudProf/EtudProf.vcxproj.user
Normal file
4
TP8/EtudProf/EtudProf.vcxproj.user
Normal 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>
|
||||
4
TP8/EtudProf/Etud_M.txt
Normal file
4
TP8/EtudProf/Etud_M.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
15103A;Aladdin;3;5;15;13;
|
||||
15095X;Jasmine;5;15;11;19;7;18;
|
||||
14109C;Asterix;4;12;10;14;8;
|
||||
19150B;Obelix;2;0;20;
|
||||
5
TP8/EtudProf/Prof_M.txt
Normal file
5
TP8/EtudProf/Prof_M.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Tournesol;3;Math;Philo;Chimie;
|
||||
Einstein;2;Physique;Méca;
|
||||
BruceLee;4;kungfu;Karaté;TaiChiChuan;Gung-Li;
|
||||
StephenWilliamHawking;2;Cosmologie;Physique;
|
||||
IsaacNewton;4;Math;Physique;Philo;Astronomie;
|
||||
220
TP8/EtudProf/main.cpp
Normal file
220
TP8/EtudProf/main.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <set>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int ENTREE_MAX = 10;
|
||||
|
||||
template <class T>
|
||||
class Personne {
|
||||
string nom;
|
||||
int nbr_entrees;
|
||||
T entrees[ENTREE_MAX];
|
||||
public:
|
||||
void Lire(ifstream& f);
|
||||
void afficher();
|
||||
T lire_entree(ifstream& f);
|
||||
|
||||
string get_key() { return nom; }
|
||||
string get_nom() { return nom; }
|
||||
};
|
||||
|
||||
class Etud : public Personne<float> {
|
||||
string Id;
|
||||
public:
|
||||
void Lire(ifstream& f);
|
||||
void afficher();
|
||||
|
||||
string get_key() { return Id; }
|
||||
};
|
||||
|
||||
class Prof : public Personne<string> {};
|
||||
|
||||
template <class M, class T>
|
||||
void lecture(M& mp, const string fname) {
|
||||
ifstream f(fname);
|
||||
|
||||
if (!f.is_open()) {
|
||||
cout << "Erreur lors de la lecture du fichier"<<endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (!f.eof()) {
|
||||
T obj;
|
||||
|
||||
obj.Lire(f);
|
||||
f.ignore();
|
||||
|
||||
mp[obj.get_key()] = obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void afficher(const C& mp) {
|
||||
for (auto pair : mp) {
|
||||
pair.second.afficher();
|
||||
cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void afficher(const set<C>& s) {
|
||||
for (auto e : s) {
|
||||
cout << e;
|
||||
cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
cout << "1 : Lire Etud_M.txt et stocker les données dans une Map1 d’Etudiants + affichage" << endl
|
||||
<< "2 : Lire Prof_M.txt et stocker les données dans une Map2 de PROFs + affichage" << endl
|
||||
<< "3 : Chercher selon le nom dans Map1 et dans Map2 si élément existe et l’Effacer + affichage" << endl
|
||||
<< "4 : Mettre les noms des étudiants et des PROFs dans un CnTri + affichage" << endl
|
||||
<< "5 : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
|
||||
cout << "Choix : ";
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
bool is_equal_ignorecase(string s1, string s2) {
|
||||
if (s1.size() != s2.size()) return false;
|
||||
for (int i = 0; i < s1.size(); i++) {
|
||||
if (tolower(s1[i]) != tolower(s2[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
auto find(T& t, const string nom) {
|
||||
auto it = t.begin();
|
||||
for (; it != t.end(); it++) {
|
||||
if (is_equal_ignorecase(it->second.get_nom(), nom))
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
void effacer_nom(map<string, Etud>& etuds, map<string, Prof>& profs) {
|
||||
string nom;
|
||||
|
||||
cout << "Nom : ";
|
||||
getline(cin, nom);
|
||||
|
||||
auto itE = find(etuds, nom);
|
||||
|
||||
auto itP = find(profs, nom);
|
||||
|
||||
if (itE == etuds.end() && itP == profs.end()) {
|
||||
cout << "Ce nom n'existe pas" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (itE != etuds.end()) {
|
||||
etuds.erase(itE);
|
||||
}
|
||||
|
||||
if (itP != profs.end()) {
|
||||
profs.erase(itP);
|
||||
}
|
||||
|
||||
afficher(etuds);
|
||||
afficher(profs);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ajout_nom(set<string>& noms, T& map) {
|
||||
for (auto& p : map) {
|
||||
noms.insert(p.second.get_nom());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
map<string, Etud> etuds;
|
||||
map<string, Prof> profs;
|
||||
|
||||
set<string> noms;
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
lecture<map<string, Etud>, Etud>(etuds, "Etud_M.txt");
|
||||
afficher(etuds);
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
lecture<map<string, Prof>, Prof>(profs, "Prof_M.txt");
|
||||
afficher(profs);
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
effacer_nom(etuds, profs);
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
noms.clear();
|
||||
ajout_nom(noms, etuds);
|
||||
ajout_nom(noms, profs);
|
||||
|
||||
afficher(noms);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Personne<T>::Lire(ifstream& f) {
|
||||
getline(f, nom, ';');
|
||||
f >> nbr_entrees; f.ignore();
|
||||
for (int i = 0; i < nbr_entrees; i++) {
|
||||
entrees[i] = lire_entree(f);
|
||||
}
|
||||
}
|
||||
|
||||
string Personne<string>::lire_entree(ifstream& f) {
|
||||
string entree;
|
||||
getline(f, entree, ';');
|
||||
return entree;
|
||||
}
|
||||
|
||||
float Personne<float>::lire_entree(ifstream& f) {
|
||||
float entree;
|
||||
f >> entree; f.ignore();
|
||||
return entree;
|
||||
}
|
||||
|
||||
|
||||
void Etud::Lire(ifstream& f) {
|
||||
getline(f, Id, ';');
|
||||
Personne::Lire(f);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Personne<T>::afficher() {
|
||||
cout << left << setw(22) << nom << " " << nbr_entrees << " ";
|
||||
for (int i = 0; i < nbr_entrees; i++) {
|
||||
cout << left << setw(8) << entrees[i] << " ";
|
||||
}
|
||||
}
|
||||
|
||||
void Etud::afficher() {
|
||||
cout << setw(6) << Id << " ";
|
||||
Personne<float>::afficher();
|
||||
}
|
||||
BIN
TP8/LocalProfEtud/Coté_Local_ ProfEtud_VF.pdf
Normal file
BIN
TP8/LocalProfEtud/Coté_Local_ ProfEtud_VF.pdf
Normal file
Binary file not shown.
31
TP8/LocalProfEtud/LocalProfEtud.sln
Normal file
31
TP8/LocalProfEtud/LocalProfEtud.sln
Normal 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
|
||||
135
TP8/LocalProfEtud/LocalProfEtud.vcxproj
Normal file
135
TP8/LocalProfEtud/LocalProfEtud.vcxproj
Normal 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>
|
||||
22
TP8/LocalProfEtud/LocalProfEtud.vcxproj.filters
Normal file
22
TP8/LocalProfEtud/LocalProfEtud.vcxproj.filters
Normal 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>
|
||||
4
TP8/LocalProfEtud/LocalProfEtud.vcxproj.user
Normal file
4
TP8/LocalProfEtud/LocalProfEtud.vcxproj.user
Normal 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
224
TP8/LocalProfEtud/main.cpp
Normal 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 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<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;
|
||||
}
|
||||
BIN
TP8/PAPILLONS/Côté_LES PAPILLONS_24.pdf
Normal file
BIN
TP8/PAPILLONS/Côté_LES PAPILLONS_24.pdf
Normal file
Binary file not shown.
31
TP8/PAPILLONS/PAPILLONS.sln
Normal file
31
TP8/PAPILLONS/PAPILLONS.sln
Normal 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}") = "PAPILLONS", "PAPILLONS.vcxproj", "{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}"
|
||||
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
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Debug|x64.Build.0 = Debug|x64
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Debug|x86.Build.0 = Debug|Win32
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Release|x64.ActiveCfg = Release|x64
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Release|x64.Build.0 = Release|x64
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Release|x86.ActiveCfg = Release|Win32
|
||||
{EA3BDFDD-EE87-4A19-BF13-B5B55F4FDE50}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {464C1159-1EE2-4873-AD3C-6E29E4DB6FB0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
139
TP8/PAPILLONS/PAPILLONS.vcxproj
Normal file
139
TP8/PAPILLONS/PAPILLONS.vcxproj
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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>{ea3bdfdd-ee87-4a19-bf13-b5b55f4fde50}</ProjectGuid>
|
||||
<RootNamespace>PAPILLONS</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>
|
||||
<Text Include="PapB.txt" />
|
||||
<Text Include="PapJ.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
TP8/PAPILLONS/PAPILLONS.vcxproj.filters
Normal file
30
TP8/PAPILLONS/PAPILLONS.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<Text Include="PapJ.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="PapB.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP8/PAPILLONS/PAPILLONS.vcxproj.user
Normal file
4
TP8/PAPILLONS/PAPILLONS.vcxproj.user
Normal 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>
|
||||
4
TP8/PAPILLONS/PapB.txt
Normal file
4
TP8/PAPILLONS/PapB.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
3
|
||||
P5;B;
|
||||
Chrys;B;
|
||||
P6;B;
|
||||
5
TP8/PAPILLONS/PapJ.txt
Normal file
5
TP8/PAPILLONS/PapJ.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
4
|
||||
P1;J;
|
||||
Bap;J;
|
||||
Buti;J;
|
||||
P4;J;
|
||||
228
TP8/PAPILLONS/main.cpp
Normal file
228
TP8/PAPILLONS/main.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Papillon {
|
||||
string Nom;
|
||||
char couleur;
|
||||
public:
|
||||
Papillon() {};
|
||||
Papillon(char couleur) : couleur(couleur) {};
|
||||
|
||||
void saisie(ifstream& f);
|
||||
void saisie();
|
||||
void afficher();
|
||||
|
||||
string nomcouleur() {
|
||||
return couleur == 'J' ? "Jaune" : "Bleu";
|
||||
}
|
||||
|
||||
char getcouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
string getnom() {
|
||||
return Nom;
|
||||
}
|
||||
|
||||
bool operator<(Papillon b) {
|
||||
return Nom > b.Nom; /* tri décroissant */
|
||||
}
|
||||
|
||||
bool operator==(Papillon p) {
|
||||
return Nom == p.Nom && couleur == p.couleur;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void lecture(T& cont, const string name) {
|
||||
ifstream f(name);
|
||||
|
||||
if (!f.is_open()) {
|
||||
cout << "Erreur lors de l'ouverture du fichier" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int n;
|
||||
|
||||
f >> n; f.ignore();
|
||||
|
||||
while (!f.eof()) {
|
||||
Papillon p;
|
||||
|
||||
p.saisie(f);
|
||||
f.ignore();
|
||||
cont.insert(cont.begin(), p);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void afficher_el(T& el) {
|
||||
el.afficher();
|
||||
}
|
||||
|
||||
void afficher_el(string el) {
|
||||
cout << el;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void afficher(T cont) {
|
||||
for (auto el : cont) {
|
||||
// el.afficher();
|
||||
afficher_el(el);
|
||||
cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void tri_affichage(T& cont) {
|
||||
sort(cont.begin(), cont.end());
|
||||
|
||||
afficher(cont);
|
||||
}
|
||||
|
||||
// spécialisation de template
|
||||
template <class A>
|
||||
void tri_affichage(list<A>& cont) {
|
||||
cont.sort(); afficher(cont);
|
||||
}
|
||||
|
||||
Papillon saisie_papillon() {
|
||||
Papillon p;
|
||||
p.saisie();
|
||||
return p;
|
||||
}
|
||||
|
||||
template <class A>
|
||||
bool effacer_papillon(A& cont, Papillon rec) {
|
||||
auto it = find(cont.begin(), cont.end(), rec);
|
||||
|
||||
if (it == cont.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cont.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void effacer_papillon(list<Papillon>& cont1, vector<Papillon>& cont2) {
|
||||
Papillon p = saisie_papillon();
|
||||
|
||||
if (!effacer_papillon(cont1, p)) {
|
||||
cout << "Papillon non trouvé dans la liste jaune"<<endl;
|
||||
}
|
||||
|
||||
if(!effacer_papillon(cont2, p)) {
|
||||
cout << "Papillon non trouvé dans le vecteur bleu" << endl;
|
||||
}
|
||||
|
||||
afficher(cont1);
|
||||
afficher(cont2);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void remplir_set(T cont, set<string>& s) {
|
||||
for (auto a : cont) {
|
||||
s.insert(a.getnom());
|
||||
}
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
|
||||
cout << "1) Lire PapJ.txt(Papillon Jaune) et stocker les données dans List" << endl
|
||||
<< "2) Lire PapB.txt(Papillon Bleu) et stocker les données dans Vector" << endl
|
||||
<< "3) Tri par ordre décroissant selon le nom + Affichage" << endl
|
||||
<< "4) Ajout d’1 Papillon dans List ou Vector selon sa couleur + Affichage" << endl
|
||||
<< "5) Cherche la position d’1 Papillon dans List et Vector et l’efface" << endl
|
||||
<< "6) Construit un SET avec les noms de tous les Papillons de List et Vector + Affichage" << endl;
|
||||
|
||||
cout << "Choix : ";
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
int main() {
|
||||
list<Papillon> j;
|
||||
vector<Papillon> b;
|
||||
|
||||
set<string> noms;
|
||||
|
||||
Papillon p;
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
lecture(j, "PapJ.txt");
|
||||
afficher(j);
|
||||
break;
|
||||
case 2:
|
||||
lecture(b, "PapB.txt");
|
||||
afficher(b);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
tri_affichage(j);
|
||||
tri_affichage(b);
|
||||
|
||||
break;
|
||||
case 4:
|
||||
p = saisie_papillon();
|
||||
if (p.getcouleur() == 'J') {
|
||||
j.push_back(p);
|
||||
afficher(j);
|
||||
}
|
||||
else {
|
||||
b.push_back(p);
|
||||
afficher(b);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
effacer_papillon(j, b);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
noms.clear();
|
||||
remplir_set(j, noms);
|
||||
remplir_set(b, noms);
|
||||
afficher(noms);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Papillon::saisie(ifstream& f) {
|
||||
getline(f, Nom, ';');
|
||||
f >> couleur; f.ignore();
|
||||
}
|
||||
|
||||
void Papillon::afficher() {
|
||||
cout << left << setw(8) << Nom << " " << nomcouleur();
|
||||
}
|
||||
|
||||
void Papillon::saisie() {
|
||||
cout << "Nom : ";
|
||||
getline(cin, Nom);
|
||||
|
||||
couleur = '\0';
|
||||
while (couleur != 'J' && couleur != 'B') {
|
||||
cout << "Couleur (J/B) : ";
|
||||
cin >> couleur; cin.ignore();
|
||||
couleur = toupper(couleur);
|
||||
}
|
||||
}
|
||||
BIN
TP8/ParcoursVita/Parcours Vita_VF.pdf
Normal file
BIN
TP8/ParcoursVita/Parcours Vita_VF.pdf
Normal file
Binary file not shown.
31
TP8/ParcoursVita/ParcoursVita.sln
Normal file
31
TP8/ParcoursVita/ParcoursVita.sln
Normal 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}") = "ParcoursVita", "ParcoursVita.vcxproj", "{E000E911-87DE-426A-A425-A796F5A8CC97}"
|
||||
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
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Debug|x64.Build.0 = Debug|x64
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Release|x64.ActiveCfg = Release|x64
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Release|x64.Build.0 = Release|x64
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E000E911-87DE-426A-A425-A796F5A8CC97}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6848ED2D-79A2-415E-B230-BEFE036DDB2C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
135
TP8/ParcoursVita/ParcoursVita.vcxproj
Normal file
135
TP8/ParcoursVita/ParcoursVita.vcxproj
Normal 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>{e000e911-87de-426a-a425-a796f5a8cc97}</ProjectGuid>
|
||||
<RootNamespace>ParcoursVita</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>
|
||||
22
TP8/ParcoursVita/ParcoursVita.vcxproj.filters
Normal file
22
TP8/ParcoursVita/ParcoursVita.vcxproj.filters
Normal 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>
|
||||
4
TP8/ParcoursVita/ParcoursVita.vcxproj.user
Normal file
4
TP8/ParcoursVita/ParcoursVita.vcxproj.user
Normal 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>
|
||||
197
TP8/ParcoursVita/main.cpp
Normal file
197
TP8/ParcoursVita/main.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Participant {
|
||||
string Nom;
|
||||
int age;
|
||||
public:
|
||||
void Affichage();
|
||||
void Saisie();
|
||||
|
||||
int getAge() { return age; }
|
||||
string getNom() { return Nom; }
|
||||
|
||||
// Tri par l'age
|
||||
bool operator<(Participant p) {
|
||||
return Nom < p.Nom;
|
||||
}
|
||||
};
|
||||
|
||||
template <class C, class T>
|
||||
void saisie(C& c) {
|
||||
int n;
|
||||
|
||||
cout << "Nombre de participants à saisir : ";
|
||||
cin >> n; cin.ignore();
|
||||
|
||||
while ((n--) > 0) {
|
||||
T participant;
|
||||
participant.Saisie();
|
||||
c.insert(c.begin(), participant);
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void affichage(C c) {
|
||||
for (auto p : c) {
|
||||
p.Affichage(); cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void affichage(set<string> c) {
|
||||
for (auto a : c) {
|
||||
cout << a << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void affichage(C c, const string name) {
|
||||
cout << "Affichage de " << name << endl;
|
||||
|
||||
affichage(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// template <class A, class B>
|
||||
bool tri_age(Participant a, Participant b) {
|
||||
return a.getAge() < b.getAge();
|
||||
}
|
||||
|
||||
// template <class A, class B>
|
||||
bool tri_age_dec(Participant a, Participant b) {
|
||||
return !tri_age(a, b);
|
||||
}
|
||||
|
||||
template <class A, class B, class F>
|
||||
void erase_max(A& a, B& b, F cmp, string txt) {
|
||||
auto ita = max_element(a.begin(), a.end(), cmp);
|
||||
auto itb = max_element(b.begin(), b.end(), cmp);
|
||||
|
||||
cout << txt;
|
||||
if (ita != a.end()
|
||||
&& (itb == b.end() || cmp(*itb, *ita))) {
|
||||
ita->Affichage();
|
||||
a.erase(ita);
|
||||
}
|
||||
else if (itb != b.end()
|
||||
&& (ita == a.end() || cmp(*ita, *itb))) {
|
||||
itb->Affichage();
|
||||
b.erase(itb);
|
||||
}
|
||||
else {
|
||||
cout << "NULL";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void erase_jeune_age(A& a, B& b) {
|
||||
erase_max(a, b, tri_age, "Le plus vieux = ");
|
||||
erase_max(a, b, tri_age_dec, "Le plus jeune = ");
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void add_allnom(A source, B& b) {
|
||||
for(auto a : source) {
|
||||
b.insert(a.getNom());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
|
||||
cout << "1. Saisie liste L1 + affichage" << endl
|
||||
<< "2. Saisie vector V1 + affichage" << endl
|
||||
<< "3. Efface le + jeune et le + agé (L1/V1)" << endl
|
||||
<< "4. Tri croissant selon age (L1/V1) + affichage" << endl
|
||||
<< "5. Conteneur de noms de L1/V1 trié+sans doublons" << endl
|
||||
<< "6. Afficher L1 et V1" << endl;
|
||||
|
||||
cout << "Choix : " << endl;
|
||||
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
int main() {
|
||||
list<Participant> L1;
|
||||
vector<Participant> V1;
|
||||
|
||||
set<string> noms;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
saisie<list<Participant>, Participant>(L1);
|
||||
affichage(L1, "L1");
|
||||
|
||||
break;
|
||||
case 2:
|
||||
saisie<vector<Participant>, Participant>(V1);
|
||||
affichage(V1, "V1");
|
||||
|
||||
break;
|
||||
case 3:
|
||||
erase_jeune_age(L1, V1);
|
||||
affichage(L1, "L1");
|
||||
affichage(V1, "V1");
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
L1.sort(tri_age);
|
||||
sort(V1.begin(), V1.end(), tri_age);
|
||||
affichage(L1, "L1");
|
||||
affichage(V1, "V1");
|
||||
|
||||
break;
|
||||
case 5:
|
||||
add_allnom(L1, noms);
|
||||
add_allnom(V1, noms);
|
||||
affichage(noms, "Affichage du conteneur :");
|
||||
|
||||
break;
|
||||
case 6:
|
||||
affichage(L1, "L1");
|
||||
affichage(V1, "V1");
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void affiche(T t, int w) {
|
||||
cout << left << setw(w) << t << " ";
|
||||
}
|
||||
|
||||
void Participant::Affichage() {
|
||||
affiche(Nom, 10);
|
||||
affiche(age, 4);
|
||||
}
|
||||
|
||||
void Participant::Saisie() {
|
||||
// Saisie de du nom : via getline();
|
||||
cout << "Son nom ? : ";
|
||||
getline(cin, Nom);
|
||||
|
||||
// Saisie de l'age
|
||||
cout << "Son age ? : ";
|
||||
cin >> age; cin.ignore();
|
||||
}
|
||||
5
TP8/Pizzeria/CLIENT.txt
Normal file
5
TP8/Pizzeria/CLIENT.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
4
|
||||
Leonardo;1;oignons;
|
||||
Raphael;1;sauce tomate;
|
||||
Donatello;3;fruits secs;champignon;poivrons;
|
||||
Michel angelo;2;fromage;sauce tomate;
|
||||
BIN
TP8/Pizzeria/Côté_La_pizzeria_VF.pdf
Normal file
BIN
TP8/Pizzeria/Côté_La_pizzeria_VF.pdf
Normal file
Binary file not shown.
7
TP8/Pizzeria/PIZZA_4.txt
Normal file
7
TP8/Pizzeria/PIZZA_4.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
6
|
||||
Vegetarienne;4;sauce tomate;poivrons;courgette;oignons;
|
||||
4 Fromages;2;creme blanche;fromage;
|
||||
Prosciutto;3;sauce tomate;fromage;jambon;
|
||||
Frutti di mare;3;sauce tomate;fromage;fruits de mer;
|
||||
Carbonara;3;creme blanche;fromage;lardons;
|
||||
Forestière;3;sauce tomate;fromage;champignon;
|
||||
31
TP8/Pizzeria/Pizzeria.sln
Normal file
31
TP8/Pizzeria/Pizzeria.sln
Normal 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}") = "Pizzeria", "Pizzeria.vcxproj", "{2370802E-F9E9-4D3C-8733-3CF28B29D22E}"
|
||||
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
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Debug|x64.Build.0 = Debug|x64
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Release|x64.ActiveCfg = Release|x64
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Release|x64.Build.0 = Release|x64
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2370802E-F9E9-4D3C-8733-3CF28B29D22E}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CECACC32-5416-4BA7-9C0E-C88B223F18A9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
139
TP8/Pizzeria/Pizzeria.vcxproj
Normal file
139
TP8/Pizzeria/Pizzeria.vcxproj
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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>{2370802e-f9e9-4d3c-8733-3cf28b29d22e}</ProjectGuid>
|
||||
<RootNamespace>Pizzeria</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>
|
||||
<Text Include="CLIENT.txt" />
|
||||
<Text Include="PIZZA_4.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
TP8/Pizzeria/Pizzeria.vcxproj.filters
Normal file
30
TP8/Pizzeria/Pizzeria.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<Text Include="PIZZA_4.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="CLIENT.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP8/Pizzeria/Pizzeria.vcxproj.user
Normal file
4
TP8/Pizzeria/Pizzeria.vcxproj.user
Normal 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>
|
||||
265
TP8/Pizzeria/main.cpp
Normal file
265
TP8/Pizzeria/main.cpp
Normal file
@@ -0,0 +1,265 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Base {
|
||||
string nom;
|
||||
vector<string> ing;
|
||||
public:
|
||||
string getNom() const { return nom; }
|
||||
vector<string> getIng() { return ing; }
|
||||
|
||||
bool operator=(Base b) { return b.nom == nom; }
|
||||
bool operator<(Base b) const { return nom < b.nom; }
|
||||
|
||||
void lecture(ifstream& f);
|
||||
void saisie();
|
||||
void affichage();
|
||||
};
|
||||
|
||||
class Pizza : public Base {
|
||||
public:
|
||||
bool contient_allergene(string allergene);
|
||||
float getPrix();
|
||||
};
|
||||
|
||||
class Client : public Base {
|
||||
public:
|
||||
bool est_allergique(Pizza p);
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class C, class T>
|
||||
void lecture(C& c, const string name) {
|
||||
ifstream f(name);
|
||||
|
||||
if (!f.is_open()) {
|
||||
cout << "Erreur lors de la lecture du fichier" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int N;
|
||||
f >> N; f.ignore();
|
||||
while ((N--) > 0) {
|
||||
T t;
|
||||
t.lecture(f);
|
||||
c.push_back(t);
|
||||
f.ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void Base::lecture(ifstream& f) {
|
||||
getline(f, nom, ';');
|
||||
int N;
|
||||
f >> N; f.ignore();
|
||||
while ((N--) > 0) {
|
||||
string t;
|
||||
getline(f, t, ';');
|
||||
ing.push_back(t);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void afficher(T t, int w) {
|
||||
cout << left << setw(w) << t << " ";
|
||||
}
|
||||
|
||||
void Base::affichage() {
|
||||
cout << nom << " : ";
|
||||
|
||||
cout << "(";
|
||||
for (int i = 0; i < ing.size()-1; i++) {
|
||||
cout << ing[i] << ", ";
|
||||
}
|
||||
if (ing.size() > 0)
|
||||
cout << ing[ing.size()-1];
|
||||
cout << ")";
|
||||
}
|
||||
|
||||
void Base::saisie() {
|
||||
cout << "Nom : ";
|
||||
getline(cin, nom);
|
||||
int N;
|
||||
cout << "Nbr ing : ";
|
||||
cin >> N; cin.ignore();
|
||||
for (int i = 0; i < N; i++) {
|
||||
string s;
|
||||
cout << "Ing" << (i + 1) << " : ";
|
||||
getline(cin, s);
|
||||
ing.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
float Pizza::getPrix() {
|
||||
return getIng().size() * 2.0;
|
||||
}
|
||||
|
||||
|
||||
template <class C>
|
||||
void affichage(C c) {
|
||||
for (auto a : c) {
|
||||
a.affichage();
|
||||
cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
bool Client::est_allergique(Pizza p) {
|
||||
for (string ing : getIng()) {
|
||||
if (p.contient_allergene(ing))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Pizza::contient_allergene(string ing) {
|
||||
for (string i : getIng()) {
|
||||
if (ing == i)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void pizza_alergenes(multimap<Client, Pizza>& mp, vector<Pizza> pizzas, list<Client> clients) {
|
||||
for (Client c : clients) {
|
||||
for (Pizza p : pizzas) {
|
||||
if (c.est_allergique(p))
|
||||
continue;
|
||||
mp.insert(make_pair(c, p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void affiche_map(multimap<Client, Pizza> mp, list<Client> clients) {
|
||||
/* auto it = mp.begin();
|
||||
while (it != mp.end()) {
|
||||
Client c = it->first;
|
||||
cout << c.getNom() << " : " << endl;
|
||||
int i = 1;
|
||||
while (it != mp.end() && it->first.getNom() == c.getNom()) {
|
||||
cout << " ";
|
||||
cout << "(" << i << ") : ";
|
||||
it->second.affichage();
|
||||
cout << endl;
|
||||
it++; i++;
|
||||
}
|
||||
cout << endl;
|
||||
} */
|
||||
clients.sort();
|
||||
for (Client c : clients) {
|
||||
cout << c.getNom() << " : " << endl;
|
||||
int i = 0;
|
||||
auto r = mp.equal_range(c);
|
||||
for (; r.first != r.second; r.first++) {
|
||||
cout << " ";
|
||||
cout << "(" << i << ") : ";
|
||||
r.first->second.affichage();
|
||||
cout << endl;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ajout_pizza(vector<Pizza>& pizzas) {
|
||||
Pizza p;
|
||||
char c;
|
||||
cout << "Ajout au début (O/N) : ";
|
||||
cin >> c; cin.ignore();
|
||||
auto it = c == 'O' ? pizzas.begin() : pizzas.end();
|
||||
|
||||
p.saisie();
|
||||
|
||||
pizzas.insert(it, p);
|
||||
|
||||
cout << "Prix calculé de cette pizza = " << p.getPrix() << " euros" << endl;
|
||||
}
|
||||
|
||||
void del_pizza(vector<Pizza>& pizzas) {
|
||||
string ing;
|
||||
cout << "Ingr_allergie : ";
|
||||
getline(cin, ing);
|
||||
|
||||
auto it = pizzas.begin();
|
||||
while (it != pizzas.end()) {
|
||||
if (it->contient_allergene(ing)) {
|
||||
it = pizzas.erase(it);
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
cout << "Il reste : ";
|
||||
for (int i = 0; i < pizzas.size()-1; i++) {
|
||||
cout << pizzas[i].getNom() << ", ";
|
||||
}
|
||||
|
||||
if (pizzas.size() > 0) {
|
||||
cout << pizzas[pizzas.size() - 1].getNom();
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
|
||||
cout << "1. Lire Pizza(s)" << endl
|
||||
<< "2. Lire Client(s)" << endl
|
||||
<< "3. Créer multimap<client, pizza>" << endl
|
||||
<< "4. Ajouter (début ou fin) pizza + prix (2euros/ing.)" << endl
|
||||
<< "5. Supprimer toutes les pizzas" << endl;
|
||||
|
||||
cout << "Choix : ";
|
||||
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
int main() {
|
||||
vector<Pizza> pizzas;
|
||||
list<Client> clients;
|
||||
|
||||
multimap<Client, Pizza> mp;
|
||||
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
lecture<vector<Pizza>, Pizza>(pizzas, "PIZZA_4.txt");
|
||||
affichage(pizzas);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
lecture<list<Client>, Client>(clients, "CLIENT.txt");
|
||||
affichage(clients);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
pizza_alergenes(mp, pizzas, clients);
|
||||
affiche_map(mp, clients);
|
||||
|
||||
break;
|
||||
case 4:
|
||||
ajout_pizza(pizzas);
|
||||
affichage(pizzas);
|
||||
|
||||
break;
|
||||
case 5:
|
||||
del_pizza(pizzas);
|
||||
affichage(pizzas);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
TP8/ROBOT/Côté_Robot_24.pdf
Normal file
BIN
TP8/ROBOT/Côté_Robot_24.pdf
Normal file
Binary file not shown.
31
TP8/ROBOT/ROBOT.sln
Normal file
31
TP8/ROBOT/ROBOT.sln
Normal 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}") = "ROBOT", "ROBOT.vcxproj", "{D8576F8D-202E-43D4-B649-16F43537FEC7}"
|
||||
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
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Debug|x64.Build.0 = Debug|x64
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Debug|x86.Build.0 = Debug|Win32
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Release|x64.ActiveCfg = Release|x64
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Release|x64.Build.0 = Release|x64
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D8576F8D-202E-43D4-B649-16F43537FEC7}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5AFDF616-7FA6-4C58-98EB-A32F1A90369E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
139
TP8/ROBOT/ROBOT.vcxproj
Normal file
139
TP8/ROBOT/ROBOT.vcxproj
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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>
|
||||
<ItemGroup>
|
||||
<Text Include="Robot1.txt" />
|
||||
<Text Include="Robot2.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{d8576f8d-202e-43d4-b649-16f43537fec7}</ProjectGuid>
|
||||
<RootNamespace>ROBOT</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>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
TP8/ROBOT/ROBOT.vcxproj.filters
Normal file
30
TP8/ROBOT/ROBOT.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<Text Include="Robot1.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
<Text Include="Robot2.txt">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
TP8/ROBOT/ROBOT.vcxproj.user
Normal file
4
TP8/ROBOT/ROBOT.vcxproj.user
Normal 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>
|
||||
7
TP8/ROBOT/Robot1.txt
Normal file
7
TP8/ROBOT/Robot1.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
6
|
||||
R;7;
|
||||
R;3;
|
||||
N;8;
|
||||
B;1;
|
||||
N;8;
|
||||
R;9;
|
||||
6
TP8/ROBOT/Robot2.txt
Normal file
6
TP8/ROBOT/Robot2.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
5
|
||||
B;3;
|
||||
B;4;
|
||||
N;8;
|
||||
R;4;
|
||||
B;2;
|
||||
264
TP8/ROBOT/main.cpp
Normal file
264
TP8/ROBOT/main.cpp
Normal file
@@ -0,0 +1,264 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Boule {
|
||||
char couleur;
|
||||
int points;
|
||||
public:
|
||||
|
||||
void saisie(ifstream& f);
|
||||
void affichage();
|
||||
|
||||
char getCouleur();
|
||||
int getPoints();
|
||||
|
||||
bool operator==(Boule b);
|
||||
bool operator<(Boule b) const;
|
||||
};
|
||||
|
||||
char Boule::getCouleur() { return couleur; }
|
||||
int Boule::getPoints() { return points; }
|
||||
|
||||
void Boule::saisie(ifstream& f) {
|
||||
f >> couleur; f.ignore();
|
||||
f >> points; f.ignore();
|
||||
}
|
||||
|
||||
void Boule::affichage() {
|
||||
cout << couleur << " : " << points;
|
||||
}
|
||||
|
||||
bool Boule::operator==(Boule b) {
|
||||
return couleur == b.couleur && points == b.points;
|
||||
}
|
||||
|
||||
bool Boule::operator<(Boule b) const {
|
||||
return (couleur == b.couleur) ? points < b.points : couleur < b.couleur;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void lec_boules(C& cont, const string fname) {
|
||||
ifstream f(fname);
|
||||
|
||||
if (!f.is_open()) {
|
||||
cout << "Erreur lors de la lecture du fichier" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cout << "Lecture du fichier " << fname << endl;
|
||||
|
||||
int N;
|
||||
|
||||
f >> N; f.ignore();
|
||||
|
||||
while ((N--) > 0) {
|
||||
Boule b;
|
||||
|
||||
b.saisie(f); f.ignore();
|
||||
cont.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void affichage(C cont) {
|
||||
for (auto a : cont) {
|
||||
a.affichage(); cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void affichage(multimap<string, C> cont) {
|
||||
|
||||
for (auto a : cont) {
|
||||
a.second.affichage(); cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class C>
|
||||
int penalite(C cont, char c) {
|
||||
int i = 0;
|
||||
for (auto a : cont) {
|
||||
if (a.getCouleur() != c) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
int Som(C cont, char c) {
|
||||
int score = 0;
|
||||
|
||||
for (auto a : cont) {
|
||||
if (a.getCouleur() == c) {
|
||||
score += a.getPoints();
|
||||
}
|
||||
else {
|
||||
score -= a.getPoints();
|
||||
}
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
// Robot1 = 1, Robot2 = 2, égalité = 0
|
||||
template <class A, class B>
|
||||
int getWinner(A a, char ac, B b, char bc) {
|
||||
int SL = Som(a, ac);
|
||||
int SV = Som(b, bc);
|
||||
|
||||
/*cout << "Score Robot1 : " << SL << endl;
|
||||
cout << "Score Robot2 : " << SV << endl;
|
||||
cout << endl;*/
|
||||
|
||||
if (SL > SV) {
|
||||
return 1;
|
||||
}
|
||||
else if (SL < SV) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void fill(multiset<Boule> &set, C c) {
|
||||
for (Boule b : c) {
|
||||
set.insert(b);
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void fill(multimap<string,Boule> &m, C& c) {
|
||||
affichage(m);
|
||||
for (auto it = c.begin(); it != c.end(); ) {
|
||||
cout << endl;
|
||||
string k = it->getCouleur() + to_string(it->getPoints());
|
||||
cout << "MMap : " << endl;
|
||||
m.insert(make_pair(k, *it));
|
||||
it = c.erase(it);
|
||||
affichage(m);
|
||||
cout << "Boules perdant : " << endl;
|
||||
affichage(c);
|
||||
}
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void del_half(C& c) {
|
||||
for (auto it = c.begin(); it != c.end();) {
|
||||
if (it != c.end()) it++;
|
||||
else break;
|
||||
|
||||
if (it != c.end())
|
||||
it = c.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int menu() {
|
||||
int c;
|
||||
|
||||
cout << "1- LectureSaisieL et Affichage " << endl
|
||||
<< "2- LectureSaisieV et Affichage" << endl
|
||||
<< "3- Compter le nombre de boules pénalisantes dans L et V" << endl
|
||||
<< "4- Qui est le gagnant? " << endl
|
||||
<< "5- Déposer les boules du Robot perdant dans une MMap" << endl
|
||||
<< "6- Afficher L, V et MMap " << endl
|
||||
<< "7- Supprimer un élément sur deux de L, V et MMap" << endl;
|
||||
cout << "Choix : ";
|
||||
cin >> c; cin.ignore();
|
||||
return c;
|
||||
}
|
||||
|
||||
int main() {
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
list<Boule> L1;
|
||||
vector<Boule> V1;
|
||||
|
||||
int winner;
|
||||
|
||||
// Je ne comprend absolument pas pourquoi il faut utiliser une multimap
|
||||
// Au lieu d'un multiset
|
||||
// Ils veulent que la clé soit couleur + score concat??!
|
||||
// C'est plus malin avec juste un set un opérateur de tri bien choisis (voir Boule::operator< )
|
||||
// Dcp je vais faire en version set et version multimap
|
||||
multimap<string, Boule> MMap;
|
||||
multiset<Boule> MSet;
|
||||
|
||||
while (true) {
|
||||
switch (menu()) {
|
||||
case 1:
|
||||
lec_boules(L1, "Robot1.txt");
|
||||
affichage(L1);
|
||||
break;
|
||||
case 2:
|
||||
lec_boules(V1, "Robot2.txt");
|
||||
affichage(V1);
|
||||
break;
|
||||
case 3:
|
||||
cout << "L : nombre de boules pénalisantes = " << penalite(L1, 'R') << endl;
|
||||
cout << "V : nombre de boules pénalisantes = " << penalite(V1, 'B') << endl;
|
||||
|
||||
break;
|
||||
case 4:
|
||||
winner = getWinner(L1, 'R', V1, 'B');
|
||||
|
||||
switch (winner) {
|
||||
case 1:
|
||||
case 2:
|
||||
cout << "Le gagnant est : Robot"<<winner << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "Pas de gagnant!" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
winner = getWinner(L1, 'R', V1, 'B');
|
||||
switch (winner) {
|
||||
case 1:
|
||||
fill(MSet, V1);
|
||||
fill(MMap, V1);
|
||||
break;
|
||||
case 2:
|
||||
fill(MSet, L1);
|
||||
fill(MMap, V1);
|
||||
break;
|
||||
default:
|
||||
cout << "Pas de gagnant!" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 6:
|
||||
cout << "L1 : " << endl;
|
||||
affichage(L1);
|
||||
cout << "V1 : " << endl;
|
||||
affichage(V1);
|
||||
cout << "MMap : " << endl;
|
||||
affichage(MMap);
|
||||
|
||||
break;
|
||||
case 7:
|
||||
del_half(L1);
|
||||
del_half(V1);
|
||||
del_half(MMap);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user