premier et dernier commit
This commit is contained in:
commit
55f924a0b6
27 changed files with 755 additions and 0 deletions
24
TP1/Makefile
Uitvoerbaar bestand
24
TP1/Makefile
Uitvoerbaar bestand
|
@ -0,0 +1,24 @@
|
|||
CXX = g++
|
||||
CXXFLAGS = -W -Wall -pedantic -g
|
||||
|
||||
|
||||
|
||||
main: main.o cellule.o figures.o file.o
|
||||
$(CXX) $(CXXFLAGS) -o main main.o figures.o cellule.o file.o
|
||||
|
||||
figures.o: figures.cpp figures.h
|
||||
$(CXX) $(CXXFLAGS) -c figures.cpp
|
||||
|
||||
cellule.o : cellule.cpp cellule.h
|
||||
$(CXX) $(CXXFLAGS) -c cellule.cpp
|
||||
|
||||
file.o : file.cpp file.h
|
||||
$(CXX) $(CXXFLAGS) -c file.cpp
|
||||
|
||||
main.o: main.cpp file.cpp cellule.cpp figures.cpp cellule.h figures.h file.h
|
||||
$(CXX) $(CXXFLAGS) -c main.cpp figures.cpp cellule.cpp file.cpp
|
||||
|
||||
clean:
|
||||
-rm file.o cellule.o figures.o main.o main
|
||||
|
||||
|
18
TP1/cellule.cpp
Normaal bestaand
18
TP1/cellule.cpp
Normaal bestaand
|
@ -0,0 +1,18 @@
|
|||
#include "figures.h"
|
||||
#include "cellule.h"
|
||||
|
||||
|
||||
|
||||
cellule::cellule(){
|
||||
suiv=NULL;
|
||||
element=NULL;
|
||||
}
|
||||
|
||||
cellule::cellule(figure *el){
|
||||
suiv=NULL;
|
||||
element=el;
|
||||
}
|
||||
|
||||
figure *cellule::get_Element(){
|
||||
return element;
|
||||
}
|
21
TP1/cellule.h
Normaal bestaand
21
TP1/cellule.h
Normaal bestaand
|
@ -0,0 +1,21 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#ifndef CELLULE_HEADER
|
||||
#define CELLULE_HEADER
|
||||
|
||||
class cellule{
|
||||
protected :
|
||||
cellule *suiv;
|
||||
figure *element;
|
||||
|
||||
public :
|
||||
cellule();
|
||||
cellule(figure *el);
|
||||
figure *get_Element();
|
||||
friend class file;
|
||||
};
|
||||
#endif
|
BIN
TP1/cellule.o
Normaal bestaand
BIN
TP1/cellule.o
Normaal bestaand
Binary file not shown.
126
TP1/figures.cpp
Normaal bestaand
126
TP1/figures.cpp
Normaal bestaand
|
@ -0,0 +1,126 @@
|
|||
#include "figures.h"
|
||||
|
||||
|
||||
|
||||
int figure::nb_instances=0;
|
||||
|
||||
int figure::get_nbInstances(){
|
||||
return nb_instances;
|
||||
}
|
||||
|
||||
void polygone::afficherCaracteristiques(){
|
||||
cout << "nombre de côtés : " << nb_cotes << endl;
|
||||
}
|
||||
|
||||
void rectangle::afficherCaracteristiques(){
|
||||
cout << "rectangle : " << endl;
|
||||
polygone::afficherCaracteristiques();
|
||||
cout << "côté 1 : " << cote_1 << ", côté 2 : " << cote_2 << endl;
|
||||
}
|
||||
|
||||
void carre::afficherCaracteristiques(){
|
||||
cout << "carre : " << endl;
|
||||
polygone::afficherCaracteristiques();
|
||||
cout << "côté : " << cote_1 << endl;
|
||||
}
|
||||
|
||||
void triangle::afficherCaracteristiques(){
|
||||
cout << "triangle : " << endl;
|
||||
polygone::afficherCaracteristiques();
|
||||
cout << "côté : " << cote << endl;
|
||||
}
|
||||
|
||||
void cercle::afficherCaracteristiques(){
|
||||
cout << "cercle : " << endl;
|
||||
cout << "rayon : " << rayon << endl;
|
||||
cout << "couleur : " << couleur << endl;
|
||||
}
|
||||
|
||||
coloriable::coloriable(){
|
||||
couleur="";
|
||||
}
|
||||
|
||||
coloriable::coloriable(string coul){
|
||||
couleur=coul;
|
||||
}
|
||||
|
||||
figure::figure(){
|
||||
nb_instances++;
|
||||
cout << "Instance après création : " << nb_instances << endl;
|
||||
}
|
||||
|
||||
polygone::polygone(int nbc) : figure(){
|
||||
nb_cotes=nbc;
|
||||
}
|
||||
|
||||
polygone::polygone() : figure(){
|
||||
nb_cotes=0;
|
||||
}
|
||||
|
||||
rectangle::rectangle(float cot1, float cot2) : polygone(4),cote_1(cot1),cote_2(cot2){}
|
||||
|
||||
rectangle::rectangle() : polygone(4){}
|
||||
|
||||
carre::carre() : rectangle(){}
|
||||
|
||||
carre::carre(float cote) : rectangle(cote,cote){}
|
||||
|
||||
triangle::triangle() : polygone(3),cote(0){}
|
||||
|
||||
triangle::triangle(float cot) : polygone(3),cote(cot){}
|
||||
|
||||
cercle::cercle() : figure(), coloriable(), rayon(0){}
|
||||
|
||||
cercle::cercle(float ray,string coul) : figure(), coloriable(coul), rayon(ray){}
|
||||
|
||||
void triangle::set_cote(float cot){
|
||||
cote=cot;
|
||||
}
|
||||
|
||||
float triangle::get_cote(){
|
||||
return cote;
|
||||
}
|
||||
|
||||
void rectangle::set_cote_1(float cot1){
|
||||
cote_1=cot1;
|
||||
}
|
||||
|
||||
void rectangle::set_cote_2(float cot2){
|
||||
cote_2=cot2;
|
||||
}
|
||||
|
||||
float rectangle::get_cote_1(){
|
||||
return cote_1;
|
||||
}
|
||||
|
||||
float rectangle::get_cote_2(){
|
||||
return cote_2;
|
||||
}
|
||||
|
||||
float cercle::get_rayon(){
|
||||
return rayon;
|
||||
}
|
||||
|
||||
void cercle::set_rayon(float ray){
|
||||
rayon=ray;
|
||||
}
|
||||
|
||||
float rectangle::perimetre(){
|
||||
return cote_1*2+cote_2*2;
|
||||
}
|
||||
|
||||
float triangle::perimetre(){
|
||||
return cote*3;
|
||||
}
|
||||
|
||||
float cercle::perimetre(){
|
||||
return 2*3.14*rayon;
|
||||
}
|
||||
|
||||
string coloriable::getCouleur(){
|
||||
return couleur;
|
||||
}
|
||||
|
||||
void coloriable::setCouleur(string coul){
|
||||
couleur=coul;
|
||||
}
|
93
TP1/figures.h
Normaal bestaand
93
TP1/figures.h
Normaal bestaand
|
@ -0,0 +1,93 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#ifndef FIGURES_HEADER
|
||||
#define FIGURES_HEADER
|
||||
|
||||
class coloriable{
|
||||
protected :
|
||||
string couleur;
|
||||
|
||||
public :
|
||||
coloriable();
|
||||
coloriable(string coul);
|
||||
string getCouleur();
|
||||
void setCouleur(string coul);
|
||||
};
|
||||
|
||||
class figure{
|
||||
|
||||
protected :
|
||||
static int nb_instances;
|
||||
|
||||
public :
|
||||
virtual float perimetre()=0;
|
||||
virtual void afficherCaracteristiques()=0;
|
||||
figure();
|
||||
static int get_nbInstances();
|
||||
};
|
||||
|
||||
class cercle : public figure , public coloriable{
|
||||
private :
|
||||
float rayon;
|
||||
|
||||
public:
|
||||
cercle();
|
||||
cercle(float rayon, string coul);
|
||||
virtual void afficherCaracteristiques();
|
||||
virtual float perimetre();
|
||||
float get_rayon();
|
||||
void set_rayon(float ray);
|
||||
};
|
||||
|
||||
class polygone : public figure{
|
||||
private :
|
||||
int nb_cotes;
|
||||
|
||||
public:
|
||||
polygone();
|
||||
polygone(int nbc);
|
||||
virtual void afficherCaracteristiques();
|
||||
virtual float perimetre()=0;
|
||||
|
||||
};
|
||||
|
||||
class rectangle : public polygone{
|
||||
protected :
|
||||
float cote_1;
|
||||
float cote_2;
|
||||
public :
|
||||
rectangle();
|
||||
rectangle(float cot1, float cot2);
|
||||
void set_cote_1(float cot1);
|
||||
void set_cote_2(float cot2);
|
||||
float get_cote_1();
|
||||
float get_cote_2();
|
||||
virtual float perimetre();
|
||||
void afficherCaracteristiques();
|
||||
};
|
||||
|
||||
class carre : public rectangle{
|
||||
public :
|
||||
carre();
|
||||
carre(float cote);
|
||||
void afficherCaracteristiques();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class triangle : public polygone{
|
||||
protected :
|
||||
float cote;
|
||||
public :
|
||||
triangle();
|
||||
triangle(float cot);
|
||||
void set_cote(float cot1);
|
||||
float get_cote();
|
||||
virtual float perimetre();
|
||||
void afficherCaracteristiques();
|
||||
};
|
||||
#endif
|
BIN
TP1/figures.o
Normaal bestaand
BIN
TP1/figures.o
Normaal bestaand
Binary file not shown.
130
TP1/file.cpp
Normaal bestaand
130
TP1/file.cpp
Normaal bestaand
|
@ -0,0 +1,130 @@
|
|||
#include "figures.h"
|
||||
#include "cellule.h"
|
||||
#include "file.h"
|
||||
|
||||
|
||||
|
||||
file::file(){
|
||||
courante=NULL;
|
||||
premiere=NULL;
|
||||
derniere=NULL;
|
||||
nb_cellules=0;
|
||||
}
|
||||
|
||||
void file::inserer_Element(figure *el){
|
||||
if(nb_cellules==0){
|
||||
courante=new cellule(el);
|
||||
premiere=courante;
|
||||
derniere=courante;
|
||||
}
|
||||
else if(derniere==courante){
|
||||
cellule *n_cellule = new cellule(el);
|
||||
n_cellule->suiv = courante->suiv;
|
||||
courante->suiv=n_cellule;
|
||||
derniere=n_cellule;
|
||||
}
|
||||
else{
|
||||
cellule *n_cellule = new cellule(el);
|
||||
n_cellule->suiv = courante->suiv;
|
||||
courante->suiv=n_cellule;
|
||||
}
|
||||
cout << "L'élément a bien été inséré" << endl;
|
||||
nb_cellules++;
|
||||
}
|
||||
|
||||
void file::supprimer_Element(){
|
||||
cellule *temp = premiere;
|
||||
try{
|
||||
while(temp->suiv!=courante){
|
||||
avancer();
|
||||
}
|
||||
if(courante==derniere){
|
||||
derniere=temp;
|
||||
}
|
||||
else if(courante!=derniere){
|
||||
temp->suiv=temp->suiv->suiv;
|
||||
}
|
||||
delete(courante);
|
||||
courante=temp;
|
||||
nb_cellules--;
|
||||
}catch(vide v){
|
||||
v.grondage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool file::est_Vide(){
|
||||
if(nb_cellules==0){
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
figure* file::file::get_Tete_De_Queue(){
|
||||
return derniere->element;
|
||||
}
|
||||
|
||||
int file::get_Nb_Elements(){
|
||||
return nb_cellules;
|
||||
}
|
||||
|
||||
cellule* file::get_Courante(){
|
||||
return courante;
|
||||
}
|
||||
|
||||
cellule* file::get_Derniere(){
|
||||
return derniere;
|
||||
}
|
||||
|
||||
void file::avancer(){
|
||||
courante=courante->suiv;
|
||||
}
|
||||
|
||||
void file::libereeeeeeeeer(){
|
||||
courante=premiere;
|
||||
cellule *liberateur;
|
||||
while(courante!=NULL){
|
||||
liberateur=courante;
|
||||
avancer();
|
||||
delete liberateur;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void file::vide::grondage(){
|
||||
cout << "Vous êtes en train de manipuler une classe vide, arrêtez tout de suite" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
35
TP1/file.h
Normaal bestaand
35
TP1/file.h
Normaal bestaand
|
@ -0,0 +1,35 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#ifndef FILE_HEADER
|
||||
#define FILE_HEADER
|
||||
|
||||
class file{
|
||||
protected :
|
||||
cellule *courante;
|
||||
cellule *premiere;
|
||||
cellule *derniere;
|
||||
int nb_cellules;
|
||||
|
||||
public :
|
||||
|
||||
file();
|
||||
void inserer_Element(figure *el);
|
||||
void supprimer_Element();
|
||||
bool est_Vide();
|
||||
figure *get_Tete_De_Queue();
|
||||
int get_Nb_Elements();
|
||||
cellule *get_Courante();
|
||||
cellule *get_Derniere();
|
||||
void avancer();
|
||||
void libereeeeeeeeer();
|
||||
|
||||
class vide {
|
||||
public:
|
||||
void grondage();
|
||||
};
|
||||
};
|
||||
#endif
|
BIN
TP1/file.o
Normaal bestaand
BIN
TP1/file.o
Normaal bestaand
Binary file not shown.
BIN
TP1/main
Uitvoerbaar bestand
BIN
TP1/main
Uitvoerbaar bestand
Binary file not shown.
49
TP1/main.cpp
Normaal bestaand
49
TP1/main.cpp
Normaal bestaand
|
@ -0,0 +1,49 @@
|
|||
#include "figures.h"
|
||||
#include "cellule.h"
|
||||
#include "file.h"
|
||||
|
||||
|
||||
int main(){
|
||||
rectangle r1=rectangle(5.6,3.1);
|
||||
carre c1=carre(5.2);
|
||||
triangle t1=triangle(5.2);
|
||||
cercle ce1=cercle(4.0,"bleu");
|
||||
|
||||
figure *tableauDeFigures[4];
|
||||
|
||||
tableauDeFigures[0]=&r1;
|
||||
tableauDeFigures[1]=&c1;
|
||||
tableauDeFigures[2]=&t1;
|
||||
tableauDeFigures[3]=&ce1;
|
||||
|
||||
cout << "Informations sur les figures du tableau : " << endl << endl;
|
||||
|
||||
for(int i=0; i< 4;i++){
|
||||
tableauDeFigures[i]->afficherCaracteristiques();
|
||||
cout << "type de figure : " << typeid(*tableauDeFigures[i]).name() << endl;
|
||||
cout << tableauDeFigures[i]->perimetre() << endl << endl;
|
||||
}
|
||||
|
||||
|
||||
cout << "On passe à la partie pointeur" << endl << endl << endl;
|
||||
|
||||
file *f1=new file();
|
||||
cout << "La file est-elle vide ? " << f1->est_Vide() << endl;;
|
||||
f1->inserer_Element(&r1);
|
||||
f1->inserer_Element(&c1);
|
||||
f1->inserer_Element(&t1);
|
||||
f1->inserer_Element(&ce1);
|
||||
cout << "Le dernier élément est : " << endl;
|
||||
f1->get_Derniere()->get_Element()->afficherCaracteristiques();
|
||||
cout << "La file est-elle vide ? " << f1->est_Vide() << endl;;
|
||||
|
||||
while(f1->get_Courante()!=NULL){
|
||||
f1->get_Courante()->get_Element()->afficherCaracteristiques();
|
||||
cout << "Périmetre : " << f1->get_Courante()->get_Element()->perimetre() << endl;
|
||||
f1->avancer();
|
||||
}
|
||||
|
||||
f1->libereeeeeeeeer();
|
||||
delete f1;
|
||||
return 0;
|
||||
}
|
BIN
TP1/main.o
Normaal bestaand
BIN
TP1/main.o
Normaal bestaand
Binary file not shown.
BIN
TP1/tp_figure.pdf
Normaal bestaand
BIN
TP1/tp_figure.pdf
Normaal bestaand
Binary file not shown.
52
TP2/Makefile
Normaal bestaand
52
TP2/Makefile
Normaal bestaand
|
@ -0,0 +1,52 @@
|
|||
CXX = g++
|
||||
CXXFLAGS = -W -Wall -pedantic -g
|
||||
|
||||
|
||||
all:exercice1.o exercice2.o exercice3.o exercice4.o exercice5.o exercice6.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice1 exercice1.o exercice2 exercice2.o exercice3 exercice3.o exercice4 exercice4.o exercice5 exercice5.o exercice6 exercice6.o
|
||||
|
||||
exercice1:exercice1.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice1 exercice1.o
|
||||
|
||||
exercice2:exercice2.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice2 exercice2.o
|
||||
|
||||
exercice3:exercice3.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice3 exercice3.o
|
||||
|
||||
exercice4:exercice4.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice4 exercice4.o
|
||||
|
||||
exercice5:exercice5.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice5 exercice5.o
|
||||
|
||||
exercice6:exercice6.o
|
||||
$(CXX) $(CXXFLAGS) -o exercice6 exercice6.o
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exercice1.o: exercice1.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice1.cpp
|
||||
|
||||
exercice2.o: exercice2.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice2.cpp
|
||||
|
||||
exercice3.o: exercice3.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice3.cpp
|
||||
|
||||
exercice4.o: exercice4.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice4.cpp
|
||||
|
||||
exercice5.o: exercice5.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice5.cpp
|
||||
|
||||
exercice6.o: exercice6.cpp
|
||||
$(CXX) $(CXXFLAGS) -c exercice6.cpp
|
||||
|
||||
|
||||
clean:
|
||||
-rm exercice1.o exercice2.o exercice3.o exercice4.o exercice5.o exercice6.o
|
||||
|
||||
|
32
TP2/exercice1.cpp
Normaal bestaand
32
TP2/exercice1.cpp
Normaal bestaand
|
@ -0,0 +1,32 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
vector<float> v1;
|
||||
for(float i=0.0;i<1.0;i+=0.1){
|
||||
v1.push_back(i);
|
||||
}
|
||||
|
||||
for(vector<float>::iterator it1 = v1.begin();it1!=v1.end();it1++){
|
||||
cout << *it1 << endl;
|
||||
}
|
||||
|
||||
cout <<"2e partie : " << endl;
|
||||
|
||||
vector<float> v2=v1;
|
||||
uint val=(v2.end()-v2.begin())/2;
|
||||
for(uint y=0; y<val;y++){
|
||||
v2.pop_back();
|
||||
}
|
||||
|
||||
for(vector<float>::iterator it3 = v2.begin();it3!=v2.end();it3++){
|
||||
cout << *it3 << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
TP2/exercice2
Uitvoerbaar bestand
BIN
TP2/exercice2
Uitvoerbaar bestand
Binary file not shown.
33
TP2/exercice2.cpp
Normaal bestaand
33
TP2/exercice2.cpp
Normaal bestaand
|
@ -0,0 +1,33 @@
|
|||
#include <iostream>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
list<char> l1;
|
||||
for(int i=65;i<65+10;i++){
|
||||
l1.push_back(i);
|
||||
cout << (char)i << endl;
|
||||
}
|
||||
|
||||
|
||||
cout << "Partie 2" << endl;
|
||||
|
||||
list<char> l2=l1;
|
||||
list<char>::iterator ii=l2.begin();
|
||||
|
||||
for(uint i=0;i<l2.size()/2;i++)ii++;
|
||||
l2.erase(l2.begin(), ii);
|
||||
|
||||
|
||||
|
||||
for(list<char>::iterator it=l2.begin();it!=l2.end();it++){
|
||||
cout << *it << endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
BIN
TP2/exercice3
Uitvoerbaar bestand
BIN
TP2/exercice3
Uitvoerbaar bestand
Binary file not shown.
36
TP2/exercice3.cpp
Normaal bestaand
36
TP2/exercice3.cpp
Normaal bestaand
|
@ -0,0 +1,36 @@
|
|||
#include <iostream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
set<string> noms_classe;
|
||||
noms_classe.insert("Roberto");
|
||||
noms_classe.insert("André");
|
||||
noms_classe.insert("Jacques");
|
||||
noms_classe.insert("Daniel");
|
||||
noms_classe.insert("Pedro");
|
||||
noms_classe.insert("Michel");
|
||||
noms_classe.insert("Alfred");
|
||||
noms_classe.insert("Pierre");
|
||||
noms_classe.insert("Denis");
|
||||
noms_classe.insert("Roger");
|
||||
noms_classe.insert("Roberto");
|
||||
noms_classe.insert("Roberta");
|
||||
|
||||
for(set<string>::iterator it=noms_classe.begin();it!=noms_classe.end();it++){
|
||||
cout << *it << endl;
|
||||
}
|
||||
|
||||
cout << "2e affichage après suppression : " << endl;
|
||||
noms_classe.erase(noms_classe.begin());
|
||||
noms_classe.erase(noms_classe.begin());
|
||||
for(set<string>::iterator it=noms_classe.begin();it!=noms_classe.end();it++){
|
||||
cout << *it << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
TP2/exercice4
Uitvoerbaar bestand
BIN
TP2/exercice4
Uitvoerbaar bestand
Binary file not shown.
40
TP2/exercice4.cpp
Normaal bestaand
40
TP2/exercice4.cpp
Normaal bestaand
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
map<string,int> agenda;
|
||||
|
||||
agenda.insert({"Roger",562578936});
|
||||
agenda.insert({"Emile",615154798});
|
||||
agenda.insert({"Jean",532659878});
|
||||
agenda.insert({"Claude",512456532});
|
||||
agenda.insert({"Pierre",514255847});
|
||||
agenda.insert({"Paul",789654578});
|
||||
agenda.insert({"Jak",223656565});
|
||||
agenda.insert({"Adil",321215454});
|
||||
agenda.insert({"Eddie",562574565});
|
||||
agenda.insert({"Eddie",562574578});
|
||||
|
||||
for(map<string,int>::iterator it=agenda.begin();it!=agenda.end();it++){
|
||||
cout << "nom : " << it->first << ", numéro : 0" << it->second << endl;
|
||||
}
|
||||
|
||||
for(map<string,int>::iterator it2=agenda.begin();it2!=agenda.end();it2++){
|
||||
if((it2->second/100000000)==5){
|
||||
cout << it2->first << " a un 05" << endl;
|
||||
agenda.erase(it2);
|
||||
}
|
||||
}
|
||||
|
||||
for(map<string,int>::iterator it3=agenda.begin();it3!=agenda.end();it3++){
|
||||
cout << "nom : " << it3->first << ", numéro : 0" << it3->second << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
TP2/exercice5
Uitvoerbaar bestand
BIN
TP2/exercice5
Uitvoerbaar bestand
Binary file not shown.
32
TP2/exercice5.cpp
Normaal bestaand
32
TP2/exercice5.cpp
Normaal bestaand
|
@ -0,0 +1,32 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
|
||||
vector<string> vecteur;
|
||||
vecteur.push_back("ballon");
|
||||
vecteur.push_back("ballon de baudruche");
|
||||
vecteur.push_back("ballon de football");
|
||||
vecteur.push_back("balai à toilettes");
|
||||
vecteur.push_back("balene bleue turquoise");
|
||||
|
||||
|
||||
for(vector<string>::iterator it=vecteur.begin(); it!=vecteur.end();it++){
|
||||
cout << *it << endl;
|
||||
}
|
||||
|
||||
sort(vecteur.begin(),vecteur.end());
|
||||
|
||||
for(vector<string>::iterator it2=vecteur.begin(); it2!=vecteur.end();it2++){
|
||||
cout << *it2 << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
TP2/exercice6
Uitvoerbaar bestand
BIN
TP2/exercice6
Uitvoerbaar bestand
Binary file not shown.
34
TP2/exercice6.cpp
Normaal bestaand
34
TP2/exercice6.cpp
Normaal bestaand
|
@ -0,0 +1,34 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(/*int argc, char const *argv[]*/)
|
||||
{
|
||||
|
||||
list<string> liste;
|
||||
liste.push_back("Il");
|
||||
liste.push_back("fait");
|
||||
liste.push_back("beau");
|
||||
|
||||
cout << "Avant : " << endl << endl;
|
||||
|
||||
for(list<string>::iterator it=liste.begin(); it!=liste.end();it++){
|
||||
cout << *it << endl;
|
||||
}
|
||||
|
||||
list<string>::iterator searcher=find(liste.begin(),liste.end(),"beau");
|
||||
liste.insert(searcher,"très");
|
||||
|
||||
cout << endl << "Après : " << endl << endl;
|
||||
|
||||
for(list<string>::iterator it2=liste.begin(); it2!=liste.end();it2++){
|
||||
cout << *it2 << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
TP2/tp_stl.pdf
Normaal bestaand
BIN
TP2/tp_stl.pdf
Normaal bestaand
Binary file not shown.
Laden…
Reference in a new issue