3 Janvier
This commit is contained in:
parent
7657d9973f
commit
a48ec5a967
@ -4,17 +4,19 @@
|
||||
|
||||
void afficheTabRec(double tab[],int taille){
|
||||
if(taille==0){
|
||||
return;
|
||||
} afficheTabRec(tab, taille-1);
|
||||
printf("%f, ",tab[taille-1]);
|
||||
printf("%.2f, ",tab[taille-1]);
|
||||
}
|
||||
|
||||
int main(){
|
||||
int i;
|
||||
double tab[15]=malloc(sizeof(double));
|
||||
double *tab = malloc(15 * sizeof (double));
|
||||
srand(time(NULL));
|
||||
for (i=0;i<15;i++){
|
||||
tab[i]=(rand()%1000);
|
||||
}
|
||||
afficheTabRec(tab, sizeof(tab));
|
||||
putchar('\n');
|
||||
return 0;
|
||||
}
|
27
DEV1.1/TP16:Recursivite/triangle.c
Normal file
27
DEV1.1/TP16:Recursivite/triangle.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user