diff --git a/APL1.1/TP12/balayage.c b/APL1.1/TP12/balayage.c new file mode 100644 index 0000000..7e5eee4 --- /dev/null +++ b/APL1.1/TP12/balayage.c @@ -0,0 +1,19 @@ +#include +#include + +//A ignorer, incomplet. + +int main(int argc, char * argv[]) { + int table[450] = {} + table[0] = 1; + table[1] = 1; + table[2] = 1; + + + + for (int i = 3; i < 900; i++) { + + } + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP12/horizontal.c b/APL1.1/TP12/horizontal.c new file mode 100644 index 0000000..03f8b51 --- /dev/null +++ b/APL1.1/TP12/horizontal.c @@ -0,0 +1,46 @@ +#include +#include + +int main(int argc, char * argv[]) { + int table1[2][5] = {}; + int table2[3][5] = {}; + int table3[5][5] = {}; + + for (int i = 0; i < 5; i++) { + table1[0][i] = i+1; + table1[1][i] = i+1; + } + + for (int i = 0; i < 15; i++) { + table2[i/5][i%5] = i+1; + } + + for (int y = 0; y < 5; y++) { + for (int x = 0; x < 5; x++) { + if (y < x) table3[x][y] = y+1; + else table3[x][y] = 0; + } + } + + for (int l = 0; l < 5; l++) { + for (int c = 0; c < 17; c++) { + if (l < 1) { + if (c < 5) printf("%2d ", table1[l][c]); + else if (c > 5 && c < 11) printf("%2d ", table2[l][c-6]); + else if (c > 11) printf("%2d ", table3[l][c-12]); + else printf(" "); + } else if (l < 2) { + if (c > 5 && c < 11) printf("%2d ", table2[l][c-6]); + else if (c > 11) printf("%2d ", table3[l][c-12]); + else printf(" "); + } else { + if (c > 11) printf("%2d ", table3[l][c-12]); + else printf(" "); + } + } + printf("\n"); + } + + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP12/magique.c b/APL1.1/TP12/magique.c new file mode 100644 index 0000000..c310b0a --- /dev/null +++ b/APL1.1/TP12/magique.c @@ -0,0 +1,32 @@ +#include +#include + +//Incomplet. + +void show2dtable(int l, int c, int table[][5]) { + for (int line = 0; line < (l*2)+1; line++) { + if (line == 0 || line == (l*2)+1 || line % 2 == 0) { + for (int col = 0; col < c; col++) printf("+-----"); + printf("+\n"); + } else { + for (int col = 0; col < c; col++) printf("| %3d ", table[line/2][col]); + printf("|\n"); + } + } +} + +int main(int argc, char * argv[]) { + int numcheck[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + int carre[3][3] = {}; + + for (int i = 0; i < 9; i ++) { + printf("Valeur case n°%d : ", i+1); + scanf("%d", carre[i%3][i/3]); + } + + for (int i = 0; i < 9; i++) { + if () + } + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP12/progressions.c b/APL1.1/TP12/progressions.c new file mode 100644 index 0000000..2c9bbf0 --- /dev/null +++ b/APL1.1/TP12/progressions.c @@ -0,0 +1,45 @@ +#include +#include + +//Affiche un tableau 2D, donnez la longueur / hauteur du tableau et il l'affichera +void show2dtable(int l, int c, int table[][5]) { + for (int line = 0; line < (l*2)+1; line++) { + if (line == 0 || line == (l*2)+1 || line % 2 == 0) { + for (int col = 0; col < c; col++) printf("+-----"); + printf("+\n"); + } else { + for (int col = 0; col < c; col++) printf("| %3d ", table[line/2][col]); + printf("|\n"); + } + } +} + +int main(int argc, char * argv[]) { + int table1[2][5] = {}; + int table2[3][5] = {}; + int table3[5][5] = {}; + + for (int i = 0; i < 5; i++) { + table1[0][i] = i+1; + table1[1][i] = i+1; + } + + for (int i = 0; i < 15; i++) { + table2[i/5][i%5] = i+1; + } + + for (int y = 0; y < 5; y++) { + for (int x = 0; x < 5; x++) { + if (y < x) table3[x][y] = y+1; + else table3[x][y] = 0; + } + } + + show2dtable(2, 5, table1); + printf("\n"); + show2dtable(3, 5, table2); + printf("\n"); + show2dtable(5, 5, table3); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP12/triangle.c b/APL1.1/TP12/triangle.c new file mode 100644 index 0000000..37026dc --- /dev/null +++ b/APL1.1/TP12/triangle.c @@ -0,0 +1,29 @@ +#include +#include + +int main(int argc, char * argv[]) { + int table[30][30] = {}; + for (int x = 0; x < 30; x++) { + for (int y = 0; y < 30; y++) { + if (y == 0 || y == x) table[x][y] = 1; else table[x][y] = 0; + } + } + + for (int l = 1; l < 30; l++) { + for (int c = 1; c < l; c++) { + int t1 = table[l-1][c-1]; + int t2 = table[l-1][c]; + + table[l][c] = t1 + t2; + } + } + + for (int l = 0; l < 15; l++) { + for (int c = 0; c <= l; c++) { + printf("%4d ", table[l][c]); + } + printf("\n"); + } + return EXIT_SUCCESS; +} +