DEV/DEV1.1/TP19/tests.c

37 lines
806 B
C
Raw Normal View History

2024-10-22 15:38:09 +02:00
# include <stdio.h>
# include <stdlib.h>
int main(void) {
2024-12-10 12:52:05 +01:00
int taille_tab = 0;
double entree;
2024-10-22 15:38:09 +02:00
double* tab = (double*) malloc(3*sizeof(double));
2024-12-10 12:52:05 +01:00
int* tab_compteurs = (int*) malloc(sizeof(int));
2024-10-22 15:38:09 +02:00
int i;
int j;
2024-12-10 12:52:05 +01:00
while( entree != (double) 'q') {
taille_tab++;
tab = (double*) realloc(tab, sizeof(double));
tab_compteurs = (int*) realloc(tab_compteurs, sizeof(int));
printf("Entrez le %de réel : ", taille_tab);
scanf("%lf", &entree);
2024-10-22 15:38:09 +02:00
getchar();
2024-12-10 12:52:05 +01:00
tab[taille_tab] = entree;
tab_compteurs[taille_tab] = 0;
2024-10-22 15:38:09 +02:00
}
2024-12-10 12:52:05 +01:00
for (i = 0; i!=taille_tab; i++) {
for (j = 0; j != taille_tab; j++) {
if (tab[j] == tab[i]) {
tab_compteurs[i] += 1;
2024-10-22 15:38:09 +02:00
}
}
}
2024-12-10 12:52:05 +01:00
for (i = 0; i!=taille_tab; i++) {
if (tab_compteurs[i] == 1) {
printf("| %lf ", tab[i]);
2024-10-22 15:38:09 +02:00
}
}
putchar('\n');
return EXIT_SUCCESS;
}