1 2 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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
/******** structure employe *********/
typedef struct Employe
{ int Id;
char Nom[3];
int Matricule;
int Salaire ;
}Employe;
/**********fonction ajouter*********/
void ajouter(int id,char nom[3],int matricule,int salaire,Employe *e)
{e->Id=id;
strcpy(e->Nom,nom);
e->Matricule=matricule;
e->Salaire=salaire;
}
/*************fonction afficher************/
void afficher(Employe *e){
printf("ID : %d\n",e->Id);
printf("Nom et Prenom : %s\n", e->Nom);
printf("Matricule : %d\n",e->Matricule);
printf("Le salaire est : %d DH \n\n ",e->Salaire);
}
/********* fonction afficher tout *****/
void affichertout(Employe tab[],int n){
int i;
for(i=0;i<n;i++)
{
printf(" ** Employe %d ** \n\n",i+1);
afficher(tab+i);
}
}
/*********** fonction modifier **********/
void modifier (int id ,int salaire,int matricule, Employe tab[],int n){
int i;
for(i=0;i<n;i++)
{
if(tab[i].Id==id)
{
tab[i].Salaire=salaire;
} }
}
/************ fonction rechercher ************************/
Employe rechercher(int id,Employe tab[],int n){
int i;
Employe a={0,"",0};
for(i=0;i<n;i++)
{
if(tab[i].Id==id )
{
a=tab[i]; //a=tab+i
break;
}
}
return a;
}
int main()
{ printf(" Liste des employes : \n\n");
Employe E[3];
Employe EP[3];
//Appel du foction ajouter
ajouter(1,"Karim ",1, 3000 ,E);
ajouter(2,"Houssni",120, 4500 ,E+1);
ajouter(3,"Alami" ,1250, 400 ,E+2);
afficher(E);//afficher un employe
affichertout(EP,2);//afficher tout les employes
return 0;
} |
Partager