Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
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
#include<stdio.h>
#include<conio.h>
typedef struct
{
	int j;
	int m;
	int a;
	}date;
typedef struct
{
	char nom[50];
	char prenom[50];
	char fonction[80];
	date d;
	float s;
	}employe;
int menu(void)
{
	int choix;   textbackground(RED);     textcolor(YELLOW);
	clrscr();
	gotoxy(3,2);textcolor(2); printf("MENU");
	gotoxy(3,5); textcolor(7); printf("1-REMPLISSAGE");
	gotoxy(3,10); printf("2-AFFICHAGE");
	gotoxy(3,15); printf("3-RECHERCHE");
	gotoxy(3,20);  printf("4-Quitter");
	do{
	gotoxy(55,35); printf("Tapez Votre Choix:");fflush(stdin);scanf("%d",&choix);
	}while(choix<1||choix>4);
	return choix;
}
void remplissage(employe b[],int *n)
{        int i;
	 char rep;
	float salaire; textbackground(YELLOW);  textcolor(BLUE);
	clrscr();
i=0;
do
{      clrscr();
	gotoxy(35,1); printf("EMPLOYE N %d :",i+1);
	gotoxy(5,5); printf("NOM:"); fflush(stdin); scanf("%s",b[i].nom);
	gotoxy(5,10); printf("PRENOM:"); fflush(stdin); scanf("%s",b[i].prenom);
	gotoxy(5,15); printf("FONCTION:"); fflush(stdin); scanf("%s",b[i].fonction);
	gotoxy(5,20); printf("Date de recrutement jj/mm/aaaa:"); fflush(stdin); scanf("%d/%d/%d",b[i].d.j,b[i].d.m,b[i].d.a);
	salaire=b[i].s;
	gotoxy(5,25); printf("SALAIRE:"); fflush(stdin);  scanf("%f",&salaire);
       gotoxy(50,40);	printf("Voulez-vous continuer O/N :"); fflush(stdin); scanf("%c",&rep);
 
	i++;
	}while(rep=='o'||rep=='O');
	(*n)++;
}
 
void affichage(employe b[],int n)
{
	int a,i;
		 textcolor(3);
	clrscr();
gotoxy(5,3); printf("NOM");
gotoxy(15,3); printf("PRENOM");
gotoxy(30,3); printf("FONCTION");
gotoxy(45,3); printf("D. RECRUTEMENT");
gotoxy(65,3); printf("SALAIRE");
 
for(i=0,a=10;i<n;i++,a+=2)
{
	gotoxy(5,a); cprintf("%s",b[i].nom);
	gotoxy(15,a); cprintf("%s",b[i].prenom);
	gotoxy(30,a); cprintf("%s",b[i].fonction);
	gotoxy(45,a); cprintf("%d/%d/%d",b[i].d.j,b[i].d.m,b[i].d.a);
	gotoxy(65,a); cprintf("%f",b[i].s);
 
}
}
char sousmenu(void)
{
	char rep;
	clrscr();
	gotoxy(5,5); cprintf("a-date de recrutement");
	gotoxy(5,15); cprintf("b-nom");
	gotoxy(35,40); printf("Tapez votre choix:"); fflush(stdin); scanf("%c",&rep);
	return rep;
	}
void tri_nom(employe b[],int n )
{
	int i,j;
	employe x;
	for(i=0;i<n-1;i++)
	for(j=i+1;j<n;j++)
	{
	if(strcmp(b[i].nom,b[j].nom>0))
	{
		x=b[i];
		b[i]=b[j];
		b[j]=x;
	}}
}
 
void main(void)
{
	employe b[80];
	int   n,c,o=1;
	clrscr();
do{
c=menu();
switch(c)
{
	case 1:{remplissage(b,&n); break;}
	case 2:switch(sousmenu())
	{
		case 'a':tri_nom(b,n);affichage(b,n); break;
		case 'b':o=1;break;
	}break;
	case 4:exit(0);break;
}
 }while(o==1);
getch();
}