8 Novembre
This commit is contained in:
parent
b035a45080
commit
a9e98afad2
14
DEV1.1/TP08:Adresses/alphabet.c
Normal file
14
DEV1.1/TP08:Adresses/alphabet.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
16
DEV1.1/TP08:Adresses/cartographie.c
Normal file
16
DEV1.1/TP08:Adresses/cartographie.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
10
DEV1.1/TP08:Adresses/conversion.c
Normal file
10
DEV1.1/TP08:Adresses/conversion.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
long long int n = 4614256656552045848LL;
|
||||
double* p = (double*) &n;
|
||||
*p=*p*2;
|
||||
printf("2pi = %f\n", *p);
|
||||
return 0;
|
||||
}
|
19
DEV1.1/TP08:Adresses/mort-vivant.c
Normal file
19
DEV1.1/TP08:Adresses/mort-vivant.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
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;
|
||||
}
|
35
DEV1.1/TP09:AllocationDynamique/singletons.c
Normal file
35
DEV1.1/TP09:AllocationDynamique/singletons.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;i<x;i++){
|
||||
v=0;
|
||||
printf("\nVeuillez saisir le reel numero %d: ",i+1);
|
||||
scanf("%lf", &r);
|
||||
if(i>0){
|
||||
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<x;i++){
|
||||
printf("%lf ",*(tab+i));
|
||||
} putchar('\n');
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user