3 Janvier

This commit is contained in:
Adrian POURCHOT 2023-01-03 11:27:42 +01:00
parent 7657d9973f
commit a48ec5a967
2 changed files with 31 additions and 2 deletions

View File

@ -4,17 +4,19 @@
void afficheTabRec(double tab[],int taille){ void afficheTabRec(double tab[],int taille){
if(taille==0){ if(taille==0){
return;
} afficheTabRec(tab, taille-1); } afficheTabRec(tab, taille-1);
printf("%f, ",tab[taille-1]); printf("%.2f, ",tab[taille-1]);
} }
int main(){ int main(){
int i; int i;
double tab[15]=malloc(sizeof(double)); double *tab = malloc(15 * sizeof (double));
srand(time(NULL)); srand(time(NULL));
for (i=0;i<15;i++){ for (i=0;i<15;i++){
tab[i]=(rand()%1000); tab[i]=(rand()%1000);
} }
afficheTabRec(tab, sizeof(tab)); afficheTabRec(tab, sizeof(tab));
putchar('\n');
return 0; return 0;
} }

View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <graph.h>
#include <string.h>
void TriangleSlerpinski(int n,int x,int y,int xx,int yy,int xxx,int yyy){
if (n==0){
DessinerSegment(x,y,xx,yy);
DessinerSegment(xx,yy,xxx,yyy);
DessinerSegment(xxx,yyy,x,y);
return;
} TriangleSlerpinski(n-1,x,y,xx+((xxx-xx)/4),(yy-((yy-y)/2)),xxx-((xxx-xx)/4),(yyy-((yy-y)/2)));
TriangleSlerpinski(n-1,xx+((xxx-xx)/4),(yy-((yy-y)/2)),xx,yy,xx+((xxx-xx)/2),yyy);
TriangleSlerpinski(n-1,xxx-((xxx-xx)/4),(yyy-((yy-y)/2)),xx+((xxx-xx)/2),yyy,xxx,yyy);
}
int main(int argc, char const *argv[])
{
int n;
n=strtol(argv[1],NULL,10);
InitialiserGraphique();
CreerFenetre(0,0,1000,1000);
TriangleSlerpinski(n,500,0,0,950,1000,950);
Touche();
FermerGraphique();
return 0;
}