Previous Next Up Index Contents

Exercice 10.12

Il y a beaucoup de solutions possibles à ce problème.

Voici probablement la solution la plus modulaire.

#include <stdio.h>

main()
{
 /* Prototypes des fonctions appelées */
 void TRIANGLE(int LIGNES);
 /* Variables locales */
 int N;
 /* Traitements */
 printf("Introduire le nombre de lignes N : ");
 scanf("%d", &N);
 TRIANGLE(N);
 return 0;
}

void TRIANGLE(int LIGNES)
{
  /* Prototypes des fonctions appelées */
 void LIGNEC(int P);
 /* Variables locales */
 int P;
 /* Traitements */
 for (P=0; P<LIGNES; P++)
      LIGNEC(P);
}
 
void LIGNEC(int P)
{
  /* Prototypes des fonctions appelées */
 double C(int P, int Q);
 /* Variables locales */
 int Q;
 /* Traitements */
 for (Q=0; Q<=P; Q++)
      printf("%6.0f", C(P,Q));
 printf("\n");
}

double C(int P, int Q)
{
  /* Prototypes des fonctions appelées */
 double FACT(int N);
 /* Traitements */
 return FACT(P)/(FACT(Q)*FACT(P-Q));
}
 
double FACT(int N)
{
 . . .
}


Previous Next Up Index Contents

Feedback - Copyright © 1993,1996,1997 F.Faber