This commit is contained in:
Bohdan Kapliuk 2024-03-28 23:06:39 +02:00
parent 231f8c368c
commit fd3c2aa232

View File

@ -33,6 +33,7 @@ int main(){
memset(funkcia,0,SIZE); memset(funkcia,0,SIZE);
char* pEnd; char* pEnd;
int counter = 0; int counter = 0;
double realRes = 0;
while (fgets(line,SIZE,stdin) && line[0] != '\n'){ while (fgets(line,SIZE,stdin) && line[0] != '\n'){
if(line == NULL){ if(line == NULL){
break; break;
@ -43,11 +44,15 @@ int main(){
counter++; counter++;
continue; continue;
} }
double r1 = round((funkcia->x + funkcia->y) * 100) / 100.0; if(funkcia->znak1 == '+')
double r2 = round((funkcia->x - funkcia->y) * 100) / 100.0; realRes = round((funkcia->x + funkcia->y) * 100) / 100.0;
double r3 = round((funkcia->x * funkcia->y) * 100) / 100.0; if(funkcia->znak1 == '-')
double r4 = round((funkcia->x / funkcia->y) * 100) / 100.0; realRes = 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->result != realRes){
results[counter] = 2; results[counter] = 2;
counter++; counter++;
continue; continue;