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
| #include<conio.h>
#include<stdio.h>
struct etudiant
{int ni;
char nm[10];
float mg;}et;
etudiant tab[10];
int i,j;
char rep;
void saisie();
void affichage();
void recherche();
void tri();
void saisie()
{int k;
for (i=0;i<=9;i++)
{clrscr();
gotoxy(40,9);puts("etudiant n° : ");
gotoxy(30,11);puts("Ni : ");
gotoxy(30,12);puts("Nom : ");
gotoxy(30,13);puts("MG : ");
gotoxy(30,14);puts("Decision : ");
k=i+1;
gotoxy(70,9);printf("%d",k);
gotoxy(60,11);scanf("%d",&tab[i].ni);
gotoxy(60,12);scanf("%s",&tab[i].nm);
gotoxy(60,13);scanf("%f",&tab[i].mg);
if (tab[i].mg >=10)
{gotoxy(60,14);puts("Admis");}
else
{gotoxy (60,14);puts("Echec");}
gotoxy (30,16);puts("une touche pour.....");
getch();
}
void affichage()
{
gotoxy(20,7);puts("Ni : ");
gotoxy(30,7);puts("Nom : ");
gotoxy(40,13);puts("MG : ");
gotoxy(50,14);puts("Decision : ");
for (i=9;i<19;i++)
{gotoxy (20,1);printf("%d",tab[i-9].ni);
gotoxy (30,1);printf("%s",tab[i-9].nm);
gotoxy (40,1);printf("%f",tab[i-9].mg);
if (tab[i-9].mg>=10)
{gotoxy (50,1)puts("Admis")}
else
{gotoxy (50,1)puts("Admis")}
}
}
void tri ()
{etudiant z;
for (i=0;i<=8;i++)
{ for (j=i+1;i<=9;j++)
{if (tab[i].mg>=tab[j].mg)
{z=tab[i];
tab[i]=tab[j];
tab[j]=z;
}
}
}
}
void recherche ()
{int rech;
int tr;
tr=0;
i=0;
gotoxy (30,9);puts("rentrer le ni :")
gotoxy (50,9);scanf("%d",& rech);
do
{if (tab[i].ni==rech)
[tr=1;}
else {i++;}
}
while ((tab[i].ni!=rech)&&(i<=9));
if (tr==1)
{printf ("%d",tab[i].ni);
printf ("%f",tab[i].mg);
printf ("%s",tab[i].nm);}
else
{puts ("etudiant introuvable");}
} |
Partager