This commit is contained in:
Weber 2024-03-28 18:29:54 +00:00
parent ff00ea7f21
commit b750faf156

View File

@ -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");