From 09627af40188225a065d7d2b1f22c85267b80869 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Tue, 31 Mar 2020 10:25:27 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du4/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4/program.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 du4/program.c diff --git a/du4/program.c b/du4/program.c new file mode 100644 index 0000000..d5860cd --- /dev/null +++ b/du4/program.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +int call(double A, double B, double C, char AC){ + if(AC=='/'&&B==0){ + return printf("CHYBA");; + } + if(AC=='+'){ + if(A+B==C)return printf("OK"); + return printf("ZLE"); + } + if(AC=='-'){ + if(A-B==C)return printf("OK"); + return printf("ZLE"); + } + if(AC=='*'){ + if(A*B==C)return printf("OK"); + return printf("ZLE"); + } + if(AC=='/'){ + if(A/B==C)return printf("OK"); + return printf("ZLE"); + } +} + +int main() +{ + + +char *str; +str=(char*)malloc(100); +double a=1,b,c; +char ac; +scanf("%s",str); +sscanf(str,"%lf%c%lf=%lf",&a,&ac,&b,&c); +//printf("%d%c%d=%d",a,ac,b,c); +call(a,b,c,ac); +//if(result) + return 0; +}