Initialization#

This commit is contained in:
Kozar 2024-03-27 14:57:38 +01:00
parent 71ce33da73
commit 2af7bc6708

View File

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int main() {
char line[100];
@ -28,7 +29,11 @@ int main() {
}
// Parse the line
sscanf(line, "%lf%c%lf=%.2lf", &num1, &op, &num2, &expected_result);
double temp_expected_result;
sscanf(line, "%lf%c%lf=%lf", &num1, &op, &num2, &temp_expected_result);
// Round the expected result to two decimal places
expected_result = round(temp_expected_result * 100) / 100.0;
// Check if the input is valid
if (op != '+' && op != '-' && op != '*' && op != '/') {
@ -62,9 +67,11 @@ int main() {
if (result == expected_result) {
printf("OK\n");
} else {
printf("%lf", expected_result);
printf("%lf", temp_expected_result);
printf("ZLE\n");
}
}
return 0;
}
}