DEV/DEV1.1/TP09:AllocationDynamique/singletons.c

35 lines
541 B
C
Raw Permalink Normal View History

2022-11-08 11:29:38 +01:00
#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;
}