Добавить 'du4/program.c'
This commit is contained in:
parent
fc1ca7eead
commit
09627af401
42
du4/program.c
Normal file
42
du4/program.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user