update
This commit is contained in:
24
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q1_Curiosite.c
Normal file
24
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q1_Curiosite.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int f(int n) {
|
||||
if (n>100)
|
||||
return n-10;
|
||||
else
|
||||
return f(f(n+11));
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, i;
|
||||
if (argc>=2){
|
||||
for (i=1; i<argc; i++){
|
||||
nb = (int) strtod(argv[i],NULL);
|
||||
printf("%d --> %d\n",nb, f(nb));
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("je veux plus de nombre en arguments !!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
48
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q2_Triangle.c
Normal file
48
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q2_Triangle.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <graph.h>
|
||||
|
||||
void fractale(int nb, int x1, int y1, int x2, int y2, int x3, int y3){
|
||||
DessinerSegment((x1+x2)/2, (y1+y2)/2, (x3+x2)/2, (y3+y2)/2);
|
||||
DessinerSegment((x3+x2)/2, (y3+y2)/2, (x3+x1)/2, (y3+y1)/2);
|
||||
DessinerSegment((x3+x1)/2, (y3+y1)/2, (x1+x2)/2, (y2+y1)/2);
|
||||
if (nb!=0){
|
||||
fractale(nb-1, x1, y1, (x1+x2)/2, (y1+y2)/2, (x1+x3)/2, (y1+y3)/2);
|
||||
fractale(nb-1, (x1+x2)/2, (y1+y2)/2, x2 ,y2, (x2+x3)/2, (y2+y3)/2);
|
||||
fractale(nb-1, (x1+x3)/2, (y1+y3)/2, (x2+x3)/2, (y2+y3)/2, x3, y3);
|
||||
}
|
||||
}
|
||||
|
||||
void triangle(int nb, int x1, int y1, int x2, int y2, int x3, int y3){
|
||||
DessinerSegment(x1, y1, x2, y2);
|
||||
DessinerSegment(x2, y2, x3, y3);
|
||||
DessinerSegment(x3, y3, x1, y1);
|
||||
fractale(nb, x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, ecran=1, forme=1080, fenetre=1080;
|
||||
if (argc>=2){
|
||||
nb = (int) strtod(argv[1],NULL);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(0,0,fenetre,fenetre);
|
||||
triangle(nb,
|
||||
fenetre/2,
|
||||
(fenetre-(sqrt(3*forme*forme/4)))/2,
|
||||
(fenetre-forme)/2,
|
||||
((sqrt(3*forme*forme/4))+fenetre)/2,
|
||||
(fenetre+forme)/2,
|
||||
((sqrt(3*forme*forme/4))+fenetre)/2);
|
||||
while(ecran){
|
||||
if (Touche()){
|
||||
ecran=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("je veux plus de nombre en arguments !!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
24
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q2_Triangle.c~
Normal file
24
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q2_Triangle.c~
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int f(int n) {
|
||||
if (n>100)
|
||||
return n-10;
|
||||
else
|
||||
return f(f(n+11));
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, i;
|
||||
if (argc>=2){
|
||||
for (i=1; i<argc; i++){
|
||||
nb = (int) strtod(argv[i],NULL);
|
||||
printf("%d --> %d\n",nb, f(nb));
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("je veux plus de nombre en arguments !!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
58
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q4_dragon.c
Normal file
58
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q4_dragon.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <graph.h>
|
||||
|
||||
typdef struct coo{
|
||||
int x;
|
||||
int y;
|
||||
} coo;LM./§
|
||||
|
||||
void calculNewPts(int* points, int max){
|
||||
int i;
|
||||
for (i=max; i>=0;i--){
|
||||
points[i*2].x = points[i].x;
|
||||
points[i*2].y = points[i].y;
|
||||
//points[i*2-1].x
|
||||
//points[i*2-1].y
|
||||
if (i==max){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 0 1
|
||||
// -1 0
|
||||
|
||||
void dragon(int nb, int* points){
|
||||
if (nb!=0){
|
||||
calculNewPts;
|
||||
dragon(nb-1, points);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, ecran=1, forme=900, fenetre=1000;
|
||||
coo* points= (coo*) malloc((pow(2,nb)+2)*sizeof(coo));
|
||||
points[0].x = 0;
|
||||
points[0].y = 0;
|
||||
points[1].x = 1;
|
||||
points[1].y = 0;
|
||||
if (argc>=2){
|
||||
nb = (int) strtod(argv[1],NULL);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(0,0,fenetre,fenetre);
|
||||
dragon(nb, points);
|
||||
while(ecran){
|
||||
if (Touche()){
|
||||
ecran=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("donnez moi un entier naturel !!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
55
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q4_dragon.c~
Normal file
55
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q4_dragon.c~
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <graph.h>
|
||||
|
||||
typdef struct coo{
|
||||
int x;
|
||||
int y;
|
||||
} coo;LM./§
|
||||
|
||||
void calculNewPts(int* points, int max){
|
||||
int i;
|
||||
for (i=max; i>=0;i--){
|
||||
points[i*2].x = points[i].x;
|
||||
points[i*2].y = points[i].y;
|
||||
//points[i*2-1].x
|
||||
//points[i*2-1].y
|
||||
if (i==max){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dragon(int nb, int* points){
|
||||
if (nb!=0){
|
||||
calculNewPts;
|
||||
dragon(nb-1, points);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, ecran=1, forme=900, fenetre=1000;
|
||||
coo* points= (coo*) malloc((pow(2,nb)+2)*sizeof(coo));
|
||||
points[0].x = 0;
|
||||
points[0].y = 0;
|
||||
points[1].x = 1;
|
||||
points[1].y = 0;
|
||||
if (argc>=2){
|
||||
nb = (int) strtod(argv[1],NULL);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(0,0,fenetre,fenetre);
|
||||
dragon(nb, points);
|
||||
while(ecran){
|
||||
if (Touche()){
|
||||
ecran=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("donnez moi un entier naturel !!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
54
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q5_Flocon.c
Normal file
54
DEV/DEV1.1_suite/TP_Recursivite_(suite)/Q5_Flocon.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
|
||||
typedef struct m{
|
||||
int x;
|
||||
int y;
|
||||
struct m* suivant;
|
||||
} maillon;
|
||||
|
||||
void ajoutDebut(maillon** p_liste, unsigned short new_valeur){
|
||||
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
|
||||
new_maillon->valeur = new_valeur;
|
||||
new_maillon->suivant = *p_liste;
|
||||
*p_liste = new_maillon;
|
||||
}
|
||||
|
||||
maillon* creerListe(int taille){
|
||||
int i;
|
||||
int valeur;
|
||||
maillon* liste = NULL;
|
||||
for (i=0; i<taille; i++){
|
||||
valeur = (rand()%889)+111;
|
||||
ajoutDebut(&liste, valeur);
|
||||
}
|
||||
return liste;
|
||||
}
|
||||
void supprListe(maillon* p_liste){
|
||||
maillon* p_suivant=p_liste;
|
||||
while (p_suivant!=NULL){
|
||||
p_suivant = p_liste->suivant;
|
||||
free(p_liste);
|
||||
p_liste=p_suivant;
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char** argv){
|
||||
int nb, ecran=1, forme=900, fenetre=1000;
|
||||
maillon* points = NULL;
|
||||
if (argc>=2){
|
||||
points=creerListe(forme, fenetre);
|
||||
nb = (int) strtod(argv[1],NULL);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(0,0,fenetre,fenetre);
|
||||
while(ecran){
|
||||
if (Touche()){
|
||||
ecran=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("donnez moi un entier naturel !!!\n");
|
||||
}
|
||||
return 0;
|
BIN
DEV/DEV1.1_suite/TP_Recursivite_(suite)/exe
Executable file
BIN
DEV/DEV1.1_suite/TP_Recursivite_(suite)/exe
Executable file
Binary file not shown.
Reference in New Issue
Block a user