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
| /* test structure révisions*/
#include <stdio.h>
#define taille 20
#define NMAX 5
struct moment
{
int heure;
int minute;
};
struct journee
{
char nom_journee[taille];
struct moment leveSoleil;
int temp;
};
/* prototype des fonctions */
void demanderMoment( struct moment *m);
void afficherMoment(struct moment m);
void demanderJournee(struct journee *j);
void afficherJournee(struct journee j);
void demanderMois(struct journee tabJ[], int nEff);
void afficherMois(struct journee tabJ[], int nEff);
/* fin des prototypes */
int main (void)
{
struct journee tabJ[NMAX];
demanderMois(&(tabJ[NMAX]), 2);
afficherMois(&(tabJ[NMAX]), 2);
return 0;
}
/* fonctions detaillées */
void demanderMoment( struct moment *m)
{
printf("quelle heure ? ");
scanf("%d", &m->heure);
printf("cb de minutes ? ");
scanf("%d", &m->minute);
}
void afficherMoment(struct moment m)
{
printf("%dh", m.heure);
printf("%d\n", m.minute);
}
void demanderJournee(struct journee *j)
{
printf("quel jour ? ");
scanf("%s", j->nom_journee);
demanderMoment(&j->leveSoleil);
printf("quelle temperature ce jour la ? ");
scanf("%d", &j->temp);
}
void afficherJournee(struct journee j)
{
printf("%s, a %dh%d, il fera %ddegre au leve du soleil\n", j.nom_journee, j.leveSoleil.heure, j.leveSoleil.minute, j.temp);
}
void demanderMois(struct journee tabJ[], int nEff)
{
int i;
for(i=0; i<nEff; i++)
{
demanderJournee(&(tabJ[i]));
}
}
void afficherMois(struct journee tabJ[], int nEff)
{
int i;
for(i =0; i<nEff; i++)
{
afficherJournee(tabJ[i]);
}
} |
Partager