This commit is contained in:
Simon SAYE BABU 2022-12-14 15:29:55 +01:00
parent 97470838b2
commit 3741430615
4 changed files with 93 additions and 0 deletions

20
DEV1.1/TP14/curiosité.c Normal file
View File

@ -0,0 +1,20 @@
#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 argc, char const *argv[])
{
printf("%d\n",f(201));
return 0;
}

32
DEV1.1/TP14/fibo.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
int fibonacci(int n)
{
if (n <= 1)
{
return 1;
}else
{
return(fibonacci(n-1)+fibonacci(n-2));
}
}
void fibonacci2(int n)
{
if (n!=0)
{
fibonacci2(n-1);
printf("%d\n",fibonacci(n));
}
}
int main(int argc, char const *argv[])
{
/*printf("%d\n", fibonacci(5));*/
fibonacci2(4);
printf("%d",!0);
return 0;
}

17
DEV1.1/TP14/phases.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
void exemple(unsigned n) {
if (n != 0) {
putchar('>');
exemple(n-1);
putchar('<');
} else
putchar('O');
}
int main(int argc, char const *argv[])
{
exemple(5);
return 0;
}

24
DEV1.1/TP14/tableau.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
void pTab(double tablax[],int i)
{
if (i>=0)
{
if (i==0)
{
printf("%.2lf\n", tablax[i]);
}else
{
printf("%.2lf ,", tablax[i]);
pTab(tablax,i-1);
}
}
}
int main(int argc, char const *argv[])
{
double tablo[5]={1,2,3,4,5};
pTab(tablo,(sizeof(tablo)/sizeof(tablo[0]))-1);
return 0;
}