| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 
 | #include <iostream>
#include<string>
class date{
	int jour;
	int mois;
	int annee;
	public:
		date(){}
		date(int a,int b,int c){
			jour=a; mois=b; annee=c;
		}
		void affiche(){
		std::cout<<jour<<"_"<<mois<<"_"<<annee<<std::endl;
		}
		date saisie_date() {
		int a,m,j;
		std::cout<<"jour";
		std::cin>>j;
		std::cout<<"mois";
		std::cin>>m;
		std::cout<<"annee";
		std::cin>>a;
		date d(j,m,a);
		return d;
		}
 
 
};
 
class employe{
	std::string nom;
	std::string prenom;
	date date_nai;
	float dern_sal;
	int cin;
    public:
    employe(){}
	employe(std::string a,std::string b, date c, float d, int e){
	nom=a;	prenom=b; date_nai=c; dern_sal=d;cin=e;
	}
	void set_nom(std::string a ){
	nom=a;
	}
	void set_prenom(std::string a){
    prenom=a;
	}
	void set_date(date a){
	date_nai=a;
	}
	void set_sal(float a){
	dern_sal=a;
	}
    void set_cin(int a){
	cin=a;
	}
    std::string get_nom(){
	return nom;
	}
	std::string get_prenom(){
	return prenom;
	}
    date get_date(){
	return date_nai;
	}
	float get_sal(){
		return dern_sal;
	}
	int get_cin(){
		return cin;
	}
	employe saisie_emp(){
		 	std::string nom;std::string prenom;date date_nai;float dern_sal;int cin;
			std::cout<<"saisie employe"<<std::endl;
		 	std::cout<<"nom";
		 	std::cin>>nom;
		 	std::cout<<"prenom";
		 	std::cin>>prenom;
		    date_nai=date_nai.saisie_date();
		 	std::cout<<"dern_sal";
		 	std::cin>>dern_sal;
		 	std::cout<<"cin";
		 	std::cin>>cin;
		 	employe e(nom,prenom,date_nai,dern_sal,cin);
		 	return e;
		 }
	};
	 class departement {
	 	int code;
	 	std::string designation;
		date date_cre;
	 	employe emp_liste[100];
	 	int nbr_emp;
		 public:
		departement (int a, date b){
	 		code=a; date_cre=b;
		 }
		 int get_code(){
		 	return code;
		 }
		 std::string get_desi(){
		 	return designation;
		 }
		 date get_date(){
		 	return date_cre ;
		 }
		 void set_code(int a){
		 	code=a;
		 	}
		void set_desi(std::string a){
		 	designation=a;
		 	}
		void set_date(date a){
			date_cre=a;
		}
 
 
		 //question 5
		 void ajouter_emp(std::string opt){
		 employe e;
		 e=e.saisie_emp();
		 if(nbr_emp==0){emp_liste[0]=e; nbr_emp++;}
		 else {if(opt=="debut"){
			 for(int i=(nbr_emp-1);i>=0;i=i-1){
		 		emp_liste[i+1]=emp_liste[i];
			 }
			 emp_liste[0]=e; nbr_emp++;
		 }
		 else{
		 	emp_liste[nbr_emp]=e; nbr_emp++;
		 }	
		 }}
		 //question 6
		 int chercher_emp(int cin){
		 	for(int i=0;i<nbr_emp;i++){
		 		if(emp_liste[i].get_cin()==cin) return i;
			 }
			 return -1;
		 }
		 //question 7
		 void modifier_emp(int cin){
			 int i=chercher_emp(cin);
			 employe e;
			 emp_liste[i]=e.saisie_emp(); 
 
			 }
		//question 8	 
		void supprimer_emp(employe e){
		int i=chercher_emp(e.get_cin());
		if(i!=-1){
		for(int j=i;j<nbr_emp-1;j++) emp_liste[j+1]=emp_liste[j];
		nbr_emp--;
		}}
 
		//question 9
		void trier(){
		int i,j;
		std::string a;
			for(i=0;i<nbr_emp-1;i++){
				for(j=i+1;j<nbr_emp;j++){
					if(emp_liste[i].get_nom()>emp_liste[j].get_nom()){
						a=emp_liste[i].get_nom();
						emp_liste[i].get_nom()=emp_liste[j].get_nom();
						emp_liste[j].get_nom()=a;
					}
				}
			}
		}
 
	 };
 
 
 
 
  int main(){
  	return 0;
  } | 
Partager