2022-03-27 10:13:22 +00:00
|
|
|
#include<stdio.h>
|
|
|
|
#include<string.h>
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
int ch=getchar();
|
|
|
|
char priklad[100];
|
|
|
|
for(int idx=0;ch!='\n'&&ch!=EOF;idx++){
|
|
|
|
priklad[idx]=ch;
|
|
|
|
ch=getchar();
|
|
|
|
}
|
|
|
|
char *start=priklad, *end=NULL;
|
|
|
|
|
|
|
|
float num1=strtof(start,&end);
|
|
|
|
if(end==start){
|
|
|
|
printf("KONIEC\n");
|
|
|
|
}
|
|
|
|
while((*start)!='+'&&(*start)!='-'&&(*start)!='/'&&(*start)!='*'){
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
char znak=(*start);
|
|
|
|
start++;
|
|
|
|
|
|
|
|
float num2=strtof(start,&end);
|
2022-03-27 12:26:01 +00:00
|
|
|
start=end;
|
|
|
|
float vysledok2=strtof(start,&end);
|
|
|
|
float vysledok=0;
|
|
|
|
|
2022-03-27 10:13:22 +00:00
|
|
|
if(num2==0&&znak=='/'){
|
|
|
|
printf("CHYBA\n");
|
|
|
|
}
|
|
|
|
if(znak=='-'){
|
|
|
|
vysledok=num1-num2;
|
|
|
|
}
|
|
|
|
else if(znak=='+'){
|
|
|
|
vysledok=num1+num2;
|
|
|
|
}
|
|
|
|
else if(znak=='*'){
|
|
|
|
vysledok=num1*num2;
|
|
|
|
}
|
|
|
|
else if(znak=='/'){
|
|
|
|
vysledok=num1/num2;
|
|
|
|
}
|
|
|
|
|
2022-03-27 12:26:01 +00:00
|
|
|
if (vysledok2-vysledok < 0.001 && vysledok2-vysledok > -0.001){
|
2022-03-27 10:13:22 +00:00
|
|
|
printf("OK\n");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
printf("ZLE\n");
|
|
|
|
}
|
|
|
|
|
2022-03-27 12:30:10 +00:00
|
|
|
// printf("%.3f\n", vysledok);
|
2022-03-27 10:13:22 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|