DEV_BUT1/DEV1.1/TP09/pascal.c

30 lines
433 B
C

#include <stdio.h>
#include <stdlib.h>
int main(void){
int acc = 0;
int tab [30][30];
int a;
int b=0;
int c;
int i;
tab [0][0] = 1;
for(i=0; i <30; i++){
for(a=0; a <= i; a++){
if (a == 0 || a == i){
tab [i][a] = 1;
}
else{
tab[i][a] = tab[i-1][a-1] + tab[i-1][a];
}
}
}
for(b = 0; b <5; b++){
for(c = 0; c <= b; c++){
printf("%5d", tab[b][c]);
}
printf("\n");
}
return EXIT_SUCCESS;
}