Initialization#
This commit is contained in:
parent
71ce33da73
commit
2af7bc6708
@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char line[100];
|
char line[100];
|
||||||
@ -28,7 +29,11 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the line
|
// 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
|
// Check if the input is valid
|
||||||
if (op != '+' && op != '-' && op != '*' && op != '/') {
|
if (op != '+' && op != '-' && op != '*' && op != '/') {
|
||||||
@ -62,6 +67,8 @@ int main() {
|
|||||||
if (result == expected_result) {
|
if (result == expected_result) {
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
} else {
|
} else {
|
||||||
|
printf("%lf", expected_result);
|
||||||
|
printf("%lf", temp_expected_result);
|
||||||
printf("ZLE\n");
|
printf("ZLE\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user