Ajout TPS + Entrainements
This commit is contained in:
@@ -2,31 +2,34 @@
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int taille_tab;
|
||||
int taille_tab = 0;
|
||||
double entree;
|
||||
double* tab = (double*) malloc(3*sizeof(double));
|
||||
int* tab_compteurs = (int*) malloc(sizeof(int));
|
||||
int i;
|
||||
int j;
|
||||
printf("Combien de réels souhaitez-vous entrer ? ");
|
||||
scanf("%d", &taille_tab);
|
||||
getchar();
|
||||
tab = (double*) realloc(tab, taille_tab*sizeof(double));
|
||||
for (i = 0; i != taille_tab; i++) {
|
||||
printf("Entrez le %de réel : ", i + 1);
|
||||
scanf("%lf", &tab[i]);
|
||||
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);
|
||||
getchar();
|
||||
tab[taille_tab] = entree;
|
||||
tab_compteurs[taille_tab] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i != (taille_tab - 1); i++) {
|
||||
for (j = i; j != taille_tab; j++) {
|
||||
if (tab[i] == tab[j]) {
|
||||
tab[j] = 0.0;
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
for (j = 0; j != taille_tab; j++) {
|
||||
if (tab[j] == tab[i]) {
|
||||
tab_compteurs[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i != taille_tab; i++) {
|
||||
if (tab[i] != 0.0) {
|
||||
printf("%.3f ", tab[i]);
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
if (tab_compteurs[i] == 1) {
|
||||
printf("| %lf ", tab[i]);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
|
Reference in New Issue
Block a user