funguje
This commit is contained in:
parent
56532263e3
commit
e8dc682eeb
23
a1/program.c
23
a1/program.c
@ -5,17 +5,12 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
char* check_math_problem(const char* problem) {
|
||||
char* result_str = (char*)malloc(10 * sizeof(char));
|
||||
if (result_str == NULL) {
|
||||
fprintf(stderr, "Error with memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
char* check_math_problem(const char* problem)
|
||||
{
|
||||
|
||||
//char* copy = strcmp(problem);
|
||||
//char* copy;
|
||||
char* copy = (char*)malloc((strlen(problem) + 1) * sizeof(char));
|
||||
strcpy(copy, problem);
|
||||
strcpy(copy, problem);
|
||||
if (copy == NULL) {
|
||||
fprintf(stderr, "Error with memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@ -74,16 +69,16 @@ char* check_math_problem(const char* problem) {
|
||||
free(copy);
|
||||
return "CHYBA";
|
||||
}
|
||||
|
||||
free(copy);
|
||||
|
||||
if (fabs(result - res) < 0.01) {
|
||||
strcpy(result_str, "OK");
|
||||
return "OK";
|
||||
} else {
|
||||
strcpy(result_str, "ZLE");
|
||||
return "ZLE";
|
||||
}
|
||||
|
||||
free(copy);
|
||||
return result_str;
|
||||
return "0";
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
Loading…
Reference in New Issue
Block a user