diff --git a/a1/program.c b/a1/program.c index fac8f7d..5b7aa7e 100644 --- a/a1/program.c +++ b/a1/program.c @@ -9,6 +9,7 @@ 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++) { @@ -17,15 +18,16 @@ int main() { break; } } + if (isEmpty) { - printf("OK\n"); continue; } - double cislo1, cislo2, vysledok_zadany; + int cislo1, cislo2; + double vysledok_zadany; char operacia; - if (sscanf(uloha, "%lf %c %lf = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) { + if (sscanf(uloha, "%d %c %d = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) { printf("CHYBA\n"); continue; } @@ -44,10 +46,10 @@ int main() { break; case '/': if (cislo2 == 0) { - printf("ZLE\n"); + printf("CHYBA\n"); continue; } - vysledok_skutocny = cislo1 / cislo2; + vysledok_skutocny = (double) cislo1 / cislo2; break; default: printf("CHYBA\n");