Изменить 'du4/program.c'
^^
This commit is contained in:
parent
27960d28e8
commit
f39dea1f67
@ -3,6 +3,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char* input = (char*) calloc(100, sizeof(char));
|
char* input = (char*) calloc(100, sizeof(char));
|
||||||
@ -76,16 +77,16 @@ int main() {
|
|||||||
LABEL:
|
LABEL:
|
||||||
switch(operation){
|
switch(operation){
|
||||||
case 1:
|
case 1:
|
||||||
printf("%s\n", (strtof(number1, &ptr) + strtof(number2, &ptr) > strtof(result, &ptr) - 0.001 && strtof(number1, &ptr) + strtof(number2, &ptr) < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
printf("%s\n", (roundf(strtof(number1, &ptr) + strtof(number2, &ptr)*100)/100 > strtof(result, &ptr) - 0.001 && roundf(strtof(number1, &ptr) + strtof(number2, &ptr)*100)/100 < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
printf("%s\n", (strtof(number1, &ptr) - strtof(number2, &ptr) > strtof(result, &ptr) - 0.001 && strtof(number1, &ptr) - strtof(number2, &ptr) < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
printf("%s\n", (roundf(strtof(number1, &ptr) - strtof(number2, &ptr)*100)/100 > strtof(result, &ptr) - 0.001 && roundf(strtof(number1, &ptr) - strtof(number2, &ptr)*100)/100 < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
printf("%s\n", (strtof(number1, &ptr) * strtof(number2, &ptr) > strtof(result, &ptr) - 0.001 && strtof(number1, &ptr) * strtof(number2, &ptr) < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
printf("%s\n", (roundf(strtof(number1, &ptr) * strtof(number2, &ptr)*100)/100 > strtof(result, &ptr) - 0.001 && roundf(strtof(number1, &ptr) * strtof(number2, &ptr)*100)/100 < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
printf("%s\n", (strtof(number1, &ptr) / strtof(number2, &ptr) > strtof(result, &ptr) - 0.001 && strtof(number1, &ptr) / strtof(number2, &ptr) < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
printf("%s\n", (roundf(strtof(number1, &ptr) / strtof(number2, &ptr)*100)/100 > strtof(result, &ptr) - 0.001 && roundf(strtof(number1, &ptr) / strtof(number2, &ptr)*100)/100 < strtof(result, &ptr) + 0.001) ? "OK" : "ZLE");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("CHYBA\n");
|
printf("CHYBA\n");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user