58 lines
987 B
C
58 lines
987 B
C
#include <stdio.h>
|
|
|
|
int main (){
|
|
char riadok[999];
|
|
char *endptr = NULL;
|
|
char need;
|
|
int i, a, vysledok = 0;
|
|
float c[99];
|
|
while(1){
|
|
char* r = fgets(riadok,999,stdin);
|
|
riadok[i++] = *r;
|
|
if(*r == '\n')
|
|
break;
|
|
}
|
|
int j = 0;
|
|
do{
|
|
if(riadok[j] == ' '){
|
|
j++;
|
|
continue;
|
|
}else if(riadok[j] == '+'){
|
|
need = riadok[j];
|
|
j++;
|
|
continue;
|
|
}else if(riadok[i] == '/'){
|
|
need = riadok[j];
|
|
j++;
|
|
continue;
|
|
}else if(riadok[i] == '-'){
|
|
need = riadok[j];
|
|
j++;
|
|
continue;
|
|
}else if(riadok[j] == '*'){
|
|
need = riadok[j];
|
|
j++;
|
|
continue;
|
|
}else if(riadok[j] == '='){
|
|
if(need == '+')
|
|
vysledok = c[0] + c[1];
|
|
else if(need == '-')
|
|
vysledok = c[0] - c[1];
|
|
else if(need == '/')
|
|
vysledok = c[0] / c[1];
|
|
else if(need == '*')
|
|
vysledok = c[0] * c[1];
|
|
j++;
|
|
continue;
|
|
}else{
|
|
float v = strtod(riadok,&endptr);
|
|
c[a] = v;
|
|
a = a + 1;
|
|
}
|
|
}while(j < i);
|
|
if(vysledok == c[2])
|
|
printf("OK\n");
|
|
else
|
|
printf("ZLE\n");
|
|
}
|