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