diff --git a/a1/program.c b/a1/program.c index abe17d0..95b19ce 100644 --- a/a1/program.c +++ b/a1/program.c @@ -1,7 +1,8 @@ + #include #include #include -#include +#include // Include string.h for strlen #define MAX_LINE_LENGTH 100 @@ -9,7 +10,6 @@ int main() { char uloha[MAX_LINE_LENGTH]; while (fgets(uloha, MAX_LINE_LENGTH, stdin) != NULL) { - int i; int isEmpty = 1; for (i = 0; uloha[i] != '\0'; i++) { @@ -23,11 +23,11 @@ int main() { continue; } - int cislo1, cislo2; + double cislo1, cislo2; double vysledok_zadany; char operacia; - if (sscanf(uloha, "%d %c %d = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) { + if (sscanf(uloha, "%lf %c %lf = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) { printf("CHYBA\n"); continue; } @@ -49,7 +49,7 @@ int main() { printf("ZLE\n"); continue; } - vysledok_skutocny = (double) cislo1 / cislo2; + vysledok_skutocny = cislo1 / cislo2; break; default: printf("CHYBA\n");