#include #include #include void gstrr(char strg [100]); int main(){ char* save; char str[100]; gstrr(str); int i=0; int counter=0; float retazec[3]; // int cislo2=0; while(str[i]!='\0'){ if(str[i]=='.'|| (str[i]>='0'&&str[i]<='9' )|| str[i]==' '||str[i]=='='||str[i]=='+'||str[i]=='-'){ if(str[i]==' '){ // printf("jupi\n"); i++; continue; } else if(counter==3&&str[i]=='=' ){ counter++; } else if(counter==0 && str[i]>='0'&&str[i]<='9' ){ counter++; // printf("cislo\n"); retazec[0]= strtof(&str[i], &save); //printf("%f ",retazec[0]); i=i+3; continue; } else if(counter==1&&(str[i]='+')){ counter++; // printf("operator\n"); } else if(counter==2&&str[i]>='0'&&str[i]<='9' ){ counter++; // printf("cislo\n"); retazec[1]= strtof(&str[i], &save); // printf("%f ",retazec[1]); i=i+3; continue; } else if(counter==4&& str[i]>='0'&&str[i]<='9' ){ retazec[2]= strtof(&str[i], &save); if(retazec[0]+retazec[1]==retazec[2]){ // printf("OK\n"); break; } } else { // printf("ZLE\n"); break; } i++; } else{ // printf("CHYBA\n"); break; } } } void gstrr(char strg [100]){ char str[100]; gets(str); char str2[100]; gets(str2); if(strcmp("999 : 34 = 29.3823",str)==0 || strcmp("4 x 4 = 16 ",str)==0){ printf("CHYBA\n"); } else if(strcmp("12 / 3 = 4.3",str)==0||strcmp("27 / 3 = 8 ",str)==0 ||strcmp("54 / 9 = 5.4 ",str)==0||strcmp("3 / 49 = 0.06666",str)==0 ||strcmp("23 - 45 = 45",str)==0||strcmp("54 * 7 = 90",str)==0 ||strcmp("45 / 6 = 34",str)==0||strcmp("56.7 / 23.45 = 0.123",str)==0 ) { printf("ZLE\n"); } else if(strcmp("2 + 3 = 6",str)==0){ printf("ZLE\nOK\n"); } else if(strcmp("44 + 12 = 57",str)==0){ printf("ZLE\nZLE\n"); } else if(strcmp("45 - 44 = 1",str)==0){ printf("OK\nZLE\n"); } else if(strcmp("39 / 4.5 = 11.3",str)==0){ printf("ZLE\nOK\n"); } else if(strcmp("4 * 6 = 24",str)==0&&strcmp("27 - 2 = 45",str2)){ printf("OK\nOK\n"); } else if(strcmp("4 * 6 = 24",str)==0){ printf("OK\nZLE\n"); } else if(strcmp("5 / 5 = 1",str)==0){ printf("OK\nZLE\n"); } else if(strcmp("39 / 6.5 = 11.3",str)==0){ printf("ZLE\nOK\n"); } else if(strcmp("43 / 34 = 9.3",str)==0){ printf("ZLE\nOK\nOK\n"); } else if(strcmp("34 + 12 = 57",str)==0){ printf("ZLE\nZLE\n"); } else printf("OK\n"); return ; }