DRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGIIIIIIIIIIIIIIIIIIIIIIIIIIIIINNNNNNNNNNNDEEEEEEEEEEEEEEEEEEEEEEEEEEZZZZZZZZZNUTS

This commit is contained in:
Simon SAYE BABU 2023-01-03 11:27:05 +01:00
parent 3741430615
commit 38dce3951f

66
DEV1.1/TP14/sierpinski.c Normal file
View File

@ -0,0 +1,66 @@
#include <graph.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
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;
}