55 lines
1.0 KiB
C
55 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
int main ()
|
|
{
|
|
int c, vysledok, i = 0;
|
|
int b[99];
|
|
bool first = true;
|
|
bool second = false;
|
|
while(1){
|
|
c = getchar();
|
|
if(c == ' ' || c == '+' || c == '\n' || c == '-' || c == '/' || c == '*' || c == '='){
|
|
if(c == '\n'){
|
|
break;
|
|
}else if(c == ' '){
|
|
continue;
|
|
}else if(c == '='){
|
|
continue;
|
|
}else if(c == '+'){
|
|
first = true;
|
|
second = true;
|
|
continue;
|
|
}else if(c == '-'){
|
|
first = false;
|
|
second = false;
|
|
continue;
|
|
}else if(c == '/'){
|
|
first = true;
|
|
second = false;
|
|
continue;
|
|
}else if(c == '*'){
|
|
first = false;
|
|
second = true;
|
|
continue;
|
|
}
|
|
}else{
|
|
c = 0;
|
|
int r = scanf("%d",&c);
|
|
b[i++] = c;
|
|
}
|
|
}
|
|
if(first == true && second == true)
|
|
vysledok = b[0] + b[1];
|
|
else if(first == false && second == false)
|
|
vysledok = b[0] - b[1];
|
|
else if(first == true && second == false)
|
|
vysledok = b[0] / b[1];
|
|
else if(first == false && second == true)
|
|
vysledok = b[0] * b[1];
|
|
if(vysledok == b[2])
|
|
printf("OK\n");
|
|
else
|
|
printf("ZLE\n");
|
|
return 0;
|
|
}
|