Skip to content
Snippets Groups Projects
Commit 0e5f08a3 authored by aprouzeau's avatar aprouzeau
Browse files

Ajout des fichiers pour le thème struct_tableau_struct.

parent f6165032
Branches
No related tags found
No related merge requests found
#include <iostream>
#include <vector>
using namespace std;
struct Eleve{
string name;
double note_TP;
double note_Partiel;
double note_Globale;
};
struct Classe{
string name;
vector<Eleve> tableau_Eleves;
};
int main(int argc, const char * argv[]) {
Eleve e1, e2, e3, e4, e5, meilleurEleve;
Classe l1;
e1.name = "Pauline";
e1.note_TP = 14;
e1.note_Partiel = 13;
e2.name = "Richard";
e2.note_TP = 18;
e2.note_Partiel = 15;
e3.name = "Albert";
e3.note_TP = 10;
e3.note_Partiel = 7;
e4.name = "Pierre";
e4.note_TP = 17;
e4.note_Partiel = 5;
e5.name = "Adèle";
e5.note_TP = 19;
e5.note_Partiel = 14;
meilleurEleve.note_Globale = 0;
l1.name = "L1";
l1.tableau_Eleves = {e1, e2, e3, e4, e5};
for(unsigned int i; i < l1.tableau_Eleves.size(); i++){
l1.tableau_Eleves[i].note_Globale = (l1.tableau_Eleves[i].note_TP + l1.tableau_Eleves[i].note_Partiel)/2.0;
if(l1.tableau_Eleves[i].note_Globale > meilleurEleve.note_Globale){
meilleurEleve = l1.tableau_Eleves[i];
}
}
cout<<meilleurEleve.name<<endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
struct Eleve{
string name;
double note_TP;
double note_Partiel;
double note_Globale;
};
struct Classe{
string name;
vector<Eleve> tableau_Eleves;
};
int main(int argc, const char * argv[]) {
Eleve e1, e2, e3, e4, e5, meilleurEleve;
Classe l1;
e1.name = "Valentin";
e1.note_TP = 15;
e1.note_Partiel = 7;
e2.name = "Caroline";
e2.note_TP = 13;
e2.note_Partiel = 16;
e3.name = "Gabriel";
e3.note_TP = 8;
e3.note_Partiel = 11;
e4.name = "Alexandra";
e4.note_TP = 17;
e4.note_Partiel = 12;
e5.name = "Maria";
e5.note_TP = 14;
e5.note_Partiel = 7;
meilleurEleve.note_Globale = 0.;
l1.name = "L1";
l1.tableau_Eleves = {e1, e2, e3, e4, e5};
for(unsigned int i; i < l1.tableau_Eleves.size(); i++){
l1.tableau_Eleves[i].note_Globale = (l1.tableau_Eleves[i].note_TP + l1.tableau_Eleves[i].note_Partiel)/2.0;
if(l1.tableau_Eleves[i].note_Globale > meilleurEleve.note_Globale){
meilleurEleve = l1.tableau_Eleves[i];
}
}
cout<<meilleurEleve.name<<endl;
return 0;
}
\ No newline at end of file
#include <iostream>
#include <vector>
using namespace std;
struct Eleve{
string name;
double note_TP;
double note_Partiel;
double note_Globale;
};
struct Classe{
string name;
vector<Eleve> tableau_Eleves;
};
int main(int argc, const char * argv[]) {
Eleve e1, e2, e3, e4, e5, meilleurEleve;
Classe l1;
e1.name = "Julien";
e1.note_TP = 13;
e1.note_Partiel = 3;
e2.name = "Jeanne";
e2.note_TP = 15;
e2.note_Partiel = 13;
e3.name = "Romain";
e3.note_TP = 16;
e3.note_Partiel = 12;
e4.name = "Elise";
e4.note_TP = 8;
e4.note_Partiel = 13;
e5.name = "Thomas";
e5.note_TP = 12;
e5.note_Partiel = 15;
meilleurEleve.note_Globale = 0.;
l1.name = "L1";
l1.tableau_Eleves = {e1, e2, e3, e4, e5};
for(unsigned int i; i < l1.tableau_Eleves.size(); i++){
l1.tableau_Eleves[i].note_Globale = (l1.tableau_Eleves[i].note_TP + l1.tableau_Eleves[i].note_Partiel)/2.0;
if(l1.tableau_Eleves[i].note_Globale > meilleurEleve.note_Globale){
meilleurEleve = l1.tableau_Eleves[i];
}
}
cout<<meilleurEleve.name<<endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment