Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class personne
- {
- private :
- char *nom;
- char *prenom;
- int age;
- public :
- personne (char* nom,char* prenom , int age)
- {
- this->nom=nom;
- this->prenom=prenom;
- this->age=age;
- }
- personne () {}
- void saisir ()
- {
- cout<<"Veuillez saisir le nom"<<endl;
- nom=(char *)malloc(50);
- cin>>nom;
- cin.ignore();
- cout<<"Veuillez saisir le prenom"<<endl;
- prenom=(char *)malloc(50);
- cin>>prenom;
- cin.ignore();
- cout<<"Veuillez saisir lage"<<endl;
- cin>>age;
- }
- void afficher ()
- {
- cout<<"Le nom de la personne est "<<nom<<endl;
- cout<<"Le prenom de la personne est "<<prenom<<endl;
- cout<<"Lage de la personne est "<<age;
- }
- };
- class etudiant : public personne
- {
- private :
- char ** matieres;
- int nbredematieres;
- float * notes;
- float moy;
- public:
- etudiant() {}
- etudiant(char* nom,char* prenom , int age,char **matieres, float* notes)
- {
- personne(nom,prenom,age);
- this->matieres=matieres;
- this->notes=notes;
- }
- void saisir ()
- {
- personne::saisir();
- cout<<"Veuillez saisir le nombre de matieres"<<endl;
- cin>>nbredematieres;
- matieres=(char **)malloc(nbredematieres*sizeof(char *));
- notes=(float *)malloc(nbredematieres*sizeof(float));
- for(int i=0;i<nbredematieres;i++)
- {
- cout<<"Veuillez saisir la matiere numero "<<i+1<<endl;
- *(matieres+i)=(char*)malloc(50*sizeof(char));
- cin>>*(matieres+i);
- cin.ignore();
- cout<<"Veuillez saisir la note numero "<<i+1<<endl;
- cin>>*(notes+i);
- }
- }
- void moyenne()
- {
- float a=0;
- for(int i=0;i<nbredematieres;i++)
- {
- a+=*(notes+i);
- }
- moy=a/nbredematieres;
- }
- void afficher()
- {
- personne::afficher();
- cout<<"Bulletin de note"<<endl;
- for(int i=0;i<nbredematieres;i++)
- {
- cout<<"Matiere "<<*(matieres+i)<<" :"<<*(notes+i)<<endl;
- }
- cout<<"la moyenne de cet etudiant est "<<moy<<endl;
- }
- float getmoy ()
- {
- return moy;
- }
- bool admis()
- {
- return (moy>=10);
- }
- int similaire (etudiant e)
- {
- if(e.getmoy()==moy) return 1; return 0;
- }
- };
- int main()
- {
- //char* a;
- //char* b;
- //a=new char[10];
- //b=new char[10];
- //cin>>a;
- //cin>>b;
- //
- //personne aziz(a,b,20);
- //aziz.afficher();
- etudiant aziz;
- aziz.saisir();
- aziz.moyenne();
- aziz.afficher();
- etudiant amine;
- amine.saisir();
- amine.moyenne();
- amine.afficher();
- cout<<aziz.similaire(amine);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement