debut pile
This commit is contained in:
BIN
DEV1.1/TP27/curiosite
Executable file
BIN
DEV1.1/TP27/curiosite
Executable file
Binary file not shown.
18
DEV1.1/TP27/curiosite.c
Normal file
18
DEV1.1/TP27/curiosite.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int f(int n) {
|
||||
if (n>100)
|
||||
return n-10;
|
||||
else
|
||||
return f(f(n+11));
|
||||
}
|
||||
|
||||
int main(){
|
||||
int i;
|
||||
for (i=0; i<101; i++)
|
||||
printf("%d\n",f(88));
|
||||
}
|
||||
|
||||
/*Pour les n<101
|
||||
f renvoie 91*/
|
||||
26
DEV1.1/TP27/triangle.c
Normal file
26
DEV1.1/TP27/triangle.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
|
||||
void triangle(int x1, int y1, int x2, int y2, int x3, int y3,int n){
|
||||
if (n == 0){
|
||||
DessinerSegment(x1, y1, x2, y2);
|
||||
DessinerSegment(x2, y2, x3, y3);
|
||||
DessinerSegment(x3, y3, x1, y1);
|
||||
}else{
|
||||
triangle(x1, y1, (x2+x1)/2, y2, (x3+x1)/2, (y3+y2)/2, n-1);
|
||||
triangle((x1+x2)/2, y1, x2, y2, (x3+x2)/2, (y3+y2)/2, n-1);
|
||||
triangle((x1+x3)/2, (y1+y3)/2, (x2+x3)/2, (y2+y3)/2, x3, y3, n-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
int n;
|
||||
printf("entrez un entier : ");
|
||||
scanf("%d",&n)
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10, 10, 1000, 800);
|
||||
triangle(10, 790, 990, 790, 500, 10, n);
|
||||
FermerGraphique();
|
||||
}
|
||||
Reference in New Issue
Block a user