2022-03-30 20:03:13 +00:00
|
|
|
#include <stdio.h>
|
2022-03-30 21:36:37 +00:00
|
|
|
|
2022-03-30 21:37:59 +00:00
|
|
|
int main(){
|
2022-03-30 21:43:10 +00:00
|
|
|
int c[999];
|
2022-03-31 08:46:47 +00:00
|
|
|
int i = 0;
|
2022-03-30 21:37:59 +00:00
|
|
|
int vysledok;
|
2022-03-30 21:36:37 +00:00
|
|
|
char riadok[999];
|
|
|
|
char *endptr = NULL;
|
2022-03-30 21:43:10 +00:00
|
|
|
char need;
|
2022-03-30 20:03:13 +00:00
|
|
|
while(1){
|
2022-03-30 21:36:37 +00:00
|
|
|
char* r = fgets(riadok,999,stdin);
|
2022-03-30 21:37:59 +00:00
|
|
|
if(*r == '\n'){
|
2022-03-30 21:36:37 +00:00
|
|
|
break;
|
2022-03-30 21:37:59 +00:00
|
|
|
}else if(*r == ' ')
|
2022-03-30 21:36:37 +00:00
|
|
|
continue;
|
2022-03-30 21:37:59 +00:00
|
|
|
else if(*r == '+'){
|
2022-03-30 21:43:10 +00:00
|
|
|
need = *r;
|
2022-03-30 21:36:37 +00:00
|
|
|
continue;
|
2022-03-30 21:37:59 +00:00
|
|
|
}else if(*r == '-'){
|
2022-03-30 21:43:10 +00:00
|
|
|
need = *r;
|
2022-03-30 21:36:37 +00:00
|
|
|
continue;
|
2022-03-30 21:37:59 +00:00
|
|
|
}else if(*r == '/'){
|
2022-03-30 21:43:10 +00:00
|
|
|
need = *r;
|
2022-03-30 21:36:37 +00:00
|
|
|
continue;
|
2022-03-30 21:37:59 +00:00
|
|
|
}else if(*r == '*'){
|
2022-03-30 21:43:10 +00:00
|
|
|
need = *r;
|
2022-03-30 21:36:37 +00:00
|
|
|
continue;
|
2022-03-30 20:03:13 +00:00
|
|
|
}else{
|
2022-03-30 21:43:10 +00:00
|
|
|
int v = strtod(riadok,&endptr);
|
2022-03-30 21:37:59 +00:00
|
|
|
c[i++] = v;
|
|
|
|
continue;
|
2022-03-30 20:03:13 +00:00
|
|
|
}
|
2022-03-30 21:37:59 +00:00
|
|
|
}
|
2022-03-30 21:43:10 +00:00
|
|
|
if(need == '+')
|
2022-03-30 21:37:59 +00:00
|
|
|
vysledok = c[0] + c[1];
|
2022-03-30 21:43:10 +00:00
|
|
|
else if(need == '-')
|
2022-03-30 21:37:59 +00:00
|
|
|
vysledok = c[0] - c[1];
|
2022-03-30 21:43:10 +00:00
|
|
|
else if(need == '/')
|
2022-03-30 21:37:59 +00:00
|
|
|
vysledok = c[0] / c[1];
|
2022-03-30 21:43:10 +00:00
|
|
|
else if(need == '*')
|
2022-03-30 21:37:59 +00:00
|
|
|
vysledok = c[0] * c[1];
|
2022-03-30 21:43:10 +00:00
|
|
|
if(vysledok == c[i])
|
2022-03-30 20:03:13 +00:00
|
|
|
printf("OK\n");
|
|
|
|
else
|
|
|
|
printf("ZLE\n");
|
2022-03-30 21:37:59 +00:00
|
|
|
return 0;
|
2022-03-30 21:43:10 +00:00
|
|
|
}
|