66 lines
957 B
C
66 lines
957 B
C
#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;
|
|
} |