18 lines
515 B
C
18 lines
515 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define FACTOR 2.54
|
|
|
|
int main(int argc, char* argv[]) {
|
|
double length = strtod(argv[1], NULL), new_length;
|
|
if (!strcmp(argv[2], "cm")) { /*On veut convertir en pouces*/
|
|
new_length = length / FACTOR;
|
|
printf("%1.3fcm = %1.3fin\n", length, new_length);
|
|
} else { /*On veut convertir en centimètres*/
|
|
new_length = length * FACTOR;
|
|
printf("%1.3fin = %1.3fcm\n", length, new_length);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
} |