APL/APL1.1/TP12/balayage.c

42 lines
674 B
C
Raw Normal View History

2021-10-05 16:18:00 +02:00
#include<stdio.h>
#include<stdlib.h>
//A ignorer, incomplet.
2021-10-11 16:58:53 +02:00
int sum(int x) {
int somme = 0;
for (int i = 0; i <= x; i++) {
somme += i;
}
return somme;
}
2021-10-05 16:18:00 +02:00
2021-10-11 16:58:53 +02:00
int main(int argc, char * argv[]) {
int table[900] = {};
int inc = 1;
int index = 0;
for (int i = 0; i < 30; i++) {
index += inc;
table[index] = 1;
table[index+1] = 1;
inc++;
}
2021-10-05 16:18:00 +02:00
2021-10-11 16:58:53 +02:00
for (int i = 0; i < 30; i++) {
int startIndex, endIndex = sum(i+1);
startIndex = endIndex - i;
2021-10-05 16:18:00 +02:00
2021-10-11 16:58:53 +02:00
for (int j = startIndex; j <= endIndex; j++) {
if (j != startIndex && j != endIndex) {
table[j] = table[j-i] + table[j-i-1];
}
printf("%3d ", table[j]);
}
printf("\n");
2021-10-05 16:18:00 +02:00
}
return EXIT_SUCCESS;
}