This commit is contained in:
Weber 2024-03-28 18:34:49 +00:00
parent 304ee55695
commit 00786a8829

View File

@ -1,7 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string.h> // 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");