diff --git a/DEV1.1/TP08:Adresses/alphabet.c b/DEV1.1/TP08:Adresses/alphabet.c new file mode 100644 index 0000000..d696d36 --- /dev/null +++ b/DEV1.1/TP08:Adresses/alphabet.c @@ -0,0 +1,14 @@ +#include +#include + +int main(void) { + char min, maj; + char *p = NULL; + + for(min = 'a', maj = 'A'; maj <= 'Z'; min++, maj++) { + p = (p == &min) ? &maj : &min; + putchar(*p); + } + putchar('\n'); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP08:Adresses/cartographie.c b/DEV1.1/TP08:Adresses/cartographie.c new file mode 100644 index 0000000..50eae3f --- /dev/null +++ b/DEV1.1/TP08:Adresses/cartographie.c @@ -0,0 +1,16 @@ +#include +#include + + +int main() { + float f=2451.927; + double d=15629.2818; + long double ld=12586818.125155; + char c='&'; + short int si=3; + int i=-56517; + long long unsigned int llui=82167258; + + printf("Voici les adresses des variables:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n",&ld,&llui,&d,&i,&f,&si,&c); +return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP08:Adresses/conversion.c b/DEV1.1/TP08:Adresses/conversion.c new file mode 100644 index 0000000..9eaaffd --- /dev/null +++ b/DEV1.1/TP08:Adresses/conversion.c @@ -0,0 +1,10 @@ +#include +#include + +int main(void) { + long long int n = 4614256656552045848LL; + double* p = (double*) &n; + *p=*p*2; + printf("2pi = %f\n", *p); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP08:Adresses/mort-vivant.c b/DEV1.1/TP08:Adresses/mort-vivant.c new file mode 100644 index 0000000..86b3553 --- /dev/null +++ b/DEV1.1/TP08:Adresses/mort-vivant.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int main(void) { + int* p; + + if(time(NULL)%2) { + int x = 59; + p = &x; + } else { + int y = 31; + p = &y; + } + printf("x=%d\n", x); + printf("y=%d\n", y); + printf("%d\n", *p); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP09:AllocationDynamique/singletons.c b/DEV1.1/TP09:AllocationDynamique/singletons.c new file mode 100644 index 0000000..32c6b4d --- /dev/null +++ b/DEV1.1/TP09:AllocationDynamique/singletons.c @@ -0,0 +1,35 @@ +#include +#include + +int main(void) { + int x; + int i; + int j; + int v; + double r; + + printf("Combien de reels voulez vous rentrer? "); + scanf("%d", &x); + double* tab = calloc(x,sizeof(double)); + for(i=0;i0){ + for(j=i-1;j>=0;j--){ + if(r==*(tab+j)){ + v=1; + break; + } + } + } else{ + *(tab+i)=r; + } if (v==0){ + *(tab+i)=r; + } + } for(i=0;i