APL/Dev1.1/Dev1910/Triangle.c
2021-10-19 16:45:56 +02:00

28 lines
533 B
C

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int P[30][30];
int N = 30 ;
int I, J;
while (N>30||N<0);
for (I=0; I<=N; I++)
{
P[I][I]=1;
P[I][0]=1;
for (J=1; J<I; J++)
P[I][J] = P[I-1][J] + P[I-1][J-1];
}
printf("Triangle de Pascal de degré %d :\n", N);
for (I=0; I<=N; I++)
{
printf(" N=%2d", I);
for (J=0; J<=I; J++)
if (P[I][J])
printf("%5d", P[I][J]);
printf("\n");
}
return EXIT_SUCCESS;
}