From 755d27882e2cb21a5e30b6854bea8e4454f2328d Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 6 Feb 2025 16:37:52 +0100 Subject: =?UTF-8?q?Ajout=20du=20TME=20et=20du=20TD=20d'info=20de=20la=20de?= =?UTF-8?q?uxi=C3=A8me=20semaine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- semestre 2/informatique/td/3- pointeurs.md | 8 +++++ .../informatique/tme/semaine2/15_triangles.c | 35 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 semestre 2/informatique/td/3- pointeurs.md create mode 100644 semestre 2/informatique/tme/semaine2/15_triangles.c diff --git a/semestre 2/informatique/td/3- pointeurs.md b/semestre 2/informatique/td/3- pointeurs.md new file mode 100644 index 0000000..7adac1d --- /dev/null +++ b/semestre 2/informatique/td/3- pointeurs.md @@ -0,0 +1,8 @@ +--- +tags: + - sorbonne + - informatique + - td +semestre: 2 +--- +j'ai déjà fait le TME et on a rien de nouveau à part la notation des pointeurs dans la pile (on utilise une flèche) \ No newline at end of file diff --git a/semestre 2/informatique/tme/semaine2/15_triangles.c b/semestre 2/informatique/tme/semaine2/15_triangles.c new file mode 100644 index 0000000..64bae2e --- /dev/null +++ b/semestre 2/informatique/tme/semaine2/15_triangles.c @@ -0,0 +1,35 @@ +#include +#define WIDTH 1000 +#define HEIGHT 1000 + +int rotate(int v1, int v2) { + return (5*v2+95*v1)/100; // version avec plus de détails, normalement c'est (v2+9*v1)/10 +} + +void triangles(int height, int width, int eps){ + int x_a, x_b, x_c; + int y_a, y_b, y_c; + x_a = 0; y_a = height-1; + x_b = width-1; y_b = height-1; + x_c = (width-1) >> 1; y_c = 0; + while ( (x_a-x_b)*(x_a-x_b) + (y_a-y_b)*(y_a-y_b) > eps*eps ){ + CINI_draw_line(x_a, y_a, x_b, y_b, "red"); + CINI_draw_line(x_a, y_a, x_c, y_c, "blue"); + CINI_draw_line(x_c, y_c, x_b, y_b, "green"); + + int old_x[] = {x_a, x_b, x_c}; + int old_y[] = {y_a, y_b, y_c}; + + x_a = rotate(old_x[0], old_x[1]); y_a = rotate(old_y[0], old_y[1]); + x_b = rotate(old_x[1], old_x[2]); y_b = rotate(old_y[1], old_y[2]); + x_c = rotate(old_x[2], old_x[0]); y_c = rotate(old_y[2], old_y[0]); + } +} + +int main(){ + CINI_open_window(WIDTH, HEIGHT, "Hello"); + CINI_fill_window("white"); + triangles(HEIGHT, WIDTH, 2); + CINI_loop(); + return 0; +} -- cgit v1.2.3