Изменить 'du4/program.c'
This commit is contained in:
parent
09627af401
commit
eb4dee21c4
@ -7,19 +7,19 @@ int call(double A, double B, double C, char AC){
|
|||||||
if(AC=='/'&&B==0){
|
if(AC=='/'&&B==0){
|
||||||
return printf("CHYBA");;
|
return printf("CHYBA");;
|
||||||
}
|
}
|
||||||
if(AC=='+'){
|
else if(AC=='+'){
|
||||||
if(A+B==C)return printf("OK");
|
if(A+B==C)return printf("OK");
|
||||||
return printf("ZLE");
|
return printf("ZLE");
|
||||||
}
|
}
|
||||||
if(AC=='-'){
|
else if(AC=='-'){
|
||||||
if(A-B==C)return printf("OK");
|
if(A-B==C)return printf("OK");
|
||||||
return printf("ZLE");
|
return printf("ZLE");
|
||||||
}
|
}
|
||||||
if(AC=='*'){
|
else if(AC=='*'){
|
||||||
if(A*B==C)return printf("OK");
|
if(A*B==C)return printf("OK");
|
||||||
return printf("ZLE");
|
return printf("ZLE");
|
||||||
}
|
}
|
||||||
if(AC=='/'){
|
else if(AC=='/'){
|
||||||
if(A/B==C)return printf("OK");
|
if(A/B==C)return printf("OK");
|
||||||
return printf("ZLE");
|
return printf("ZLE");
|
||||||
}
|
}
|
||||||
@ -31,12 +31,20 @@ int main()
|
|||||||
|
|
||||||
char *str;
|
char *str;
|
||||||
str=(char*)malloc(100);
|
str=(char*)malloc(100);
|
||||||
double a=1,b,c;
|
double a,b,c;
|
||||||
char ac;
|
char ac,el;
|
||||||
scanf("%s",str);
|
int ind=0;
|
||||||
|
for(int i=0;el!='\n';i++){
|
||||||
|
el=getchar();
|
||||||
|
if(isspace(el)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
str[ind]=el;
|
||||||
|
ind++;
|
||||||
|
}
|
||||||
|
//scanf("%s",str);
|
||||||
sscanf(str,"%lf%c%lf=%lf ",&a,&ac,&b,&c);
|
sscanf(str,"%lf%c%lf=%lf ",&a,&ac,&b,&c);
|
||||||
//printf("%d%c%d=%d",a,ac,b,c);
|
//printf("%f %d %f =%f",a,ac,b,c);
|
||||||
call(a,b,c,ac);
|
call(a,b,c,ac);
|
||||||
//if(result)
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user