#include #include #include #include void add(double a, double b, double c,char ac, int result[],int count){ float cc=a+b; if(cc==(float)c || a+b==c) result[count]=1; else result[count]=2; } void subtr(double a, double b, double c,char ac, int result[],int count){ if(a-b==c) result[count]=1; else result[count]=2; } void multi(double a, double b, double c,char ac, int result[],int count){ if(a*b==c) result[count]=1; else result[count]=2; } void divi(double a, double b, double c,char ac, int result[],int count){ float cc=a/b; double Cc=(int)((a/b)*100000); if(cc==c || a/b==c || Cc==(int)(c*100000)) result[count]=1; else result[count]=2; } int main() { char *str; int *result; result=(int*)malloc(100); double a,b,c; char ac,el=0; int count=0; int eof; int ro=0; for(;eof!=EOF;count++){ eof=0; int k=0; str=(char*)malloc(100); int ind=0; for(int i=0;eof!='\n';i++){ eof=getchar(); if(eof==EOF) break; if(eof=='='){ ro=1; } if(!isdigit(eof) && eof!='.' && eof!=' '){ k++; } if(eof!=' '){ str[ind]=eof; ind++; } } if(ro==0){ printf("CHYBA\n"); break; } if(eof==EOF) break; sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c); free(str); if(k>3){ result[count]=3; continue; } switch(ac){ case '+': add(a,b,c,ac,result,count); break; case '-': subtr(a,b,c,ac,result,count); break; case '*': multi(a,b,c,ac,result,count); break; case '/': divi(a,b,c,ac,result,count); break; default: result[count]=3; } } count--; for(int j=0;j