diff --git a/a1/program.c b/a1/program.c index 871ce67..91ae2e4 100644 --- a/a1/program.c +++ b/a1/program.c @@ -33,6 +33,7 @@ int main(){ memset(funkcia,0,SIZE); char* pEnd; int counter = 0; + double realRes = 0; while (fgets(line,SIZE,stdin) && line[0] != '\n'){ if(line == NULL){ break; @@ -43,11 +44,15 @@ int main(){ counter++; continue; } - double r1 = round((funkcia->x + funkcia->y) * 100) / 100.0; - double r2 = round((funkcia->x - funkcia->y) * 100) / 100.0; - double r3 = round((funkcia->x * funkcia->y) * 100) / 100.0; - double r4 = round((funkcia->x / funkcia->y) * 100) / 100.0; - if(funkcia->result != r1 && funkcia->result != r2 && funkcia->result != r3 && funkcia->result != r4){ + if(funkcia->znak1 == '+') + realRes = round((funkcia->x + funkcia->y) * 100) / 100.0; + if(funkcia->znak1 == '-') + realRes = round((funkcia->x - funkcia->y) * 100) / 100.0; + if(funkcia->znak1 == '*') + realRes = round((funkcia->x * funkcia->y) * 100) / 100.0; + if(funkcia->znak1 == '/') + realRes = round((funkcia->x / funkcia->y) * 100) / 100.0; + if(funkcia->result != realRes){ results[counter] = 2; counter++; continue;