From 38dce3951f09020242f67d2e32436c457d52f5ab Mon Sep 17 00:00:00 2001 From: Simon Saye Babu Date: Tue, 3 Jan 2023 11:27:05 +0100 Subject: [PATCH] DRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGIIIIIIIIIIIIIIIIIIIIIIIIIIIIINNNNNNNNNNNDEEEEEEEEEEEEEEEEEEEEEEEEEEZZZZZZZZZNUTS --- DEV1.1/TP14/sierpinski.c | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 DEV1.1/TP14/sierpinski.c diff --git a/DEV1.1/TP14/sierpinski.c b/DEV1.1/TP14/sierpinski.c new file mode 100644 index 0000000..6f6d47f --- /dev/null +++ b/DEV1.1/TP14/sierpinski.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include + +void triangle(int l,int h,int x,int y) +{ + DessinerSegment(x,y,x+l,y); + DessinerSegment(x+l,y,x+(l/2),y-h); + DessinerSegment(x+(l/2),y-h,x,y); +} + +void sierpinski(int n,int l,int h,int x,int y) +{ + if (n==0) + { + triangle(l,h,x,y); + } + else + { + sierpinski(n-1,l/2,h/2,x,y); + sierpinski(n-1,l/2,h/2,x+l/2,y); + sierpinski(n-1,l/2,h/2,x+(l/4),y-h/2); + } +} + +void dragindeeznutz(int n,int x,int y,int xx,int yy) +{ + if (n==1) + { + DessinerSegment(x,y,xx,yy); + } + else + { + if (n%2==0) + { + dragindeeznutz(n-1,x,y,x,yy); + dragindeeznutz(n-1,x,yy,xx,yy); + } + else + { + dragindeeznutz(n-1,x,y,x+y,y-x); + dragindeeznutz(n-1,x+y,y-x,xx,yy); + } + } + +} + +int main(int argc, char const *argv[]) +{ + + InitialiserGraphique(); + CreerFenetre(10,10,1000,1000); + int x,y; + x=50; + y=950; + + dragindeeznutz(4,50,900,500,500); + + + Touche(); + FermerGraphique(); + + return 0; +} \ No newline at end of file