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