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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
struct identification {
int num;
char section[20];
};
struct date {
int jours;
int mois;
int annee;
};
struct etudiant {
struct identification id;
char nom[20];
char prenom[20];
struct date date_naiss;
float tnotes[10];
float moy;
};
int ne,nn;
struct etudiant *te;
struct etudiant *p;
float *pn;
p=te;
do
{ printf ("Donnez le nombre d'etudiant :");
scanf ("%d",&ne);
}while ((ne<2)||(ne>20));
te=(struct etudiant*)malloc(ne*(sizeof(struct etudiant)));
do
{ printf ("Donnez le nombre de notes :");
scanf ("%d",&nn);
}while((nn<2)||(nn>10));
for (p=te;p<te+ne;p++)
{ printf ("Donnez le num de l'etudiant :");
scanf ("%d",p->id.num);
printf ("Donnez la section de l'etudiant :");
scanf ("%s",p->id.section);
printf ("Donnez le nom de l'etudiant :");
scanf ("%s",p->nom);
printf ("Donnez le prenom de l'etudiant :");
scanf ("%s",p->prenom);
printf ("Donnez le jour de naissance de l'etudiant :");
scanf ("%d",p->date_naiss.jours);
printf ("Donnez le mois de naissance de l'etudiant :");
scanf ("%d",p->date_naiss.mois);
printf ("Donnez l'annee de naissance de l'etudiant :");
scanf ("%d",p->date_naiss.annee);
for (pn=p->tnotes;pn<(tnotes+nn);pn++)
{do
{printf ("Donnez les notes :");
scanf ("%f",pn);
}while ((*pn<0)||(*pn>20));
}
}
} |
Partager