37 lines
647 B
C
37 lines
647 B
C
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
# define HAUTEUR 30
|
|
|
|
int main(void) {
|
|
int t[HAUTEUR][HAUTEUR];
|
|
/* Création du triangle de Pascal */
|
|
int k;
|
|
int n;
|
|
for (k = 0; k != HAUTEUR; k++) {
|
|
for (n = 0; n != HAUTEUR; n++) {
|
|
if (k == n && k >= 0) {
|
|
t[k][n] = 1;
|
|
}
|
|
else if (k > n && n >= 1) {
|
|
t[k][n] = t[k-1][n] + t[k-1][n-1];
|
|
}
|
|
else if (k>=0 && n == 0) {
|
|
t[k][n] = 1;
|
|
}
|
|
else {
|
|
t[k][n] = 0;
|
|
}
|
|
}
|
|
}
|
|
/* Affichage */
|
|
for (k = 0; k != HAUTEUR; k++) {
|
|
for (n = 0; n != HAUTEUR; n++) {
|
|
if (t[k][n] != 0) {
|
|
printf("%d ", t[k][n]);
|
|
}
|
|
}
|
|
printf("\n");
|
|
}
|
|
printf("\n");
|
|
return EXIT_SUCCESS;
|
|
} |