Изменить 'du4/program.c'
This commit is contained in:
parent
2d291ebe9a
commit
1c8b217cb3
@ -3,29 +3,28 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int call( double A, double B, double C, char AC){
|
||||
double cC=(double)C;
|
||||
if(AC=='/'&&B==0 || AC==('+'||'-'||'*'||'-')){
|
||||
return printf("CHYBA\n");
|
||||
}
|
||||
else if(AC=='+'){
|
||||
if(A+B==C || C==cC)return printf("OK\n");
|
||||
char add(double A, double B, double C,char AC){
|
||||
if(A+B==C)return printf("OK\n");
|
||||
printf("%lf",A+B);
|
||||
return printf("ZLE\n");
|
||||
}
|
||||
if(AC=='-'){
|
||||
char subtr(double A, double B, double C,char AC){
|
||||
if(A-B==C)return printf("OK\n");
|
||||
printf("%lf",A-B);
|
||||
return printf("ZLE\n");
|
||||
}
|
||||
if(AC=='*'){
|
||||
char multi(double A, double B, double C,char AC){
|
||||
if(A*B==C)return printf("OK\n");
|
||||
printf("%lf",A*B);
|
||||
return printf("ZLE\n");
|
||||
}
|
||||
if(AC=='/'){
|
||||
if(A/B==C || A/B==cC || C==cC)return printf("OK\n");
|
||||
char divi(double A, double B, double C,char AC){
|
||||
float CC=A/B;
|
||||
printf("%f",CC);
|
||||
if(CC==C || A/B==C)return printf("OK\n");
|
||||
printf("%lf",A/B);
|
||||
return printf("ZLE\n");
|
||||
}
|
||||
return printf("CHYBA\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -42,11 +41,12 @@ for(int i=0;el!='\n';i++){
|
||||
str[ind]=el;
|
||||
ind++;
|
||||
}
|
||||
//134.5␣/␣6.7␣=␣20.07462686567164
|
||||
//scanf("%s",str);
|
||||
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
||||
//printf("\n%Lf %c %Lf =%Lf ",a,ac,b,c);
|
||||
call(a,b,c,ac);
|
||||
if(ac=='+')add(a,b,c,ac);
|
||||
if(ac=='-')subtr(a,b,c,ac);
|
||||
if(ac=='*')multi(a,b,c,ac);
|
||||
if(ac=='/')divi(a,b,c,ac);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user