APL/APL1.2/TP01/singletons.c

33 lines
535 B
C
Raw Normal View History

2021-11-09 15:50:11 +01:00
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char * argv[]) {
if (argc < 3) {
puts("Veuillez renseigner deux valeurs ou plus.");
return EXIT_FAILURE;
}
double* list = (double*) calloc(argc-1, sizeof(double));
for (int i = 0; i < argc-1; i++) {
double val = strtod(argv[i+1], NULL);
int found = 0;
for (int j = 0; j < i; j++) {
if (list[j] == val) found = 1;
}
if (!found) {
list[i] = val;
printf("%.2f ", val);
}
}
free(list);
printf("\n");
return EXIT_SUCCESS;
}