2022-03-27 13:35:56 +00:00
|
|
|
#include<math.h>
|
2022-03-27 10:13:22 +00:00
|
|
|
#include<stdio.h>
|
|
|
|
#include<string.h>
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
int ch=getchar();
|
2022-03-27 13:12:07 +00:00
|
|
|
char priklad[300];
|
2022-03-27 13:19:33 +00:00
|
|
|
int count=0;
|
2022-03-27 13:12:07 +00:00
|
|
|
|
|
|
|
for(int idx=0;1;idx++){
|
2022-03-27 10:13:22 +00:00
|
|
|
priklad[idx]=ch;
|
2022-03-27 13:19:33 +00:00
|
|
|
if(ch=='\n'){
|
|
|
|
count++;
|
|
|
|
}
|
2022-03-27 10:13:22 +00:00
|
|
|
ch=getchar();
|
2022-03-27 13:25:29 +00:00
|
|
|
if((priklad[idx]=='\n'&&ch=='\n')||ch==EOF){
|
2022-03-27 13:12:07 +00:00
|
|
|
break;
|
2022-03-27 13:19:33 +00:00
|
|
|
}
|
2022-03-27 10:13:22 +00:00
|
|
|
}
|
2022-03-27 13:19:33 +00:00
|
|
|
|
|
|
|
char *start=priklad, *end=NULL;
|
|
|
|
|
|
|
|
for(int c=0;c<count;c++){
|
2022-03-27 10:13:22 +00:00
|
|
|
|
|
|
|
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;
|
2022-03-27 12:59:58 +00:00
|
|
|
while(((*start)<'0'||(*start)>'9')&&(*start)!='-'){
|
2022-03-27 12:47:33 +00:00
|
|
|
start++;
|
|
|
|
}
|
|
|
|
|
2022-03-27 12:26:01 +00:00
|
|
|
float vysledok2=strtof(start,&end);
|
2022-03-27 13:30:17 +00:00
|
|
|
start=end;
|
2022-03-27 12:48:59 +00:00
|
|
|
//printf("%f\n",vysledok2);
|
2022-03-27 12:26:01 +00:00
|
|
|
float vysledok=0;
|
2022-03-27 12:35:37 +00:00
|
|
|
|
2022-03-27 13:02:35 +00:00
|
|
|
/*if(num2==0&&znak=='/'){
|
2022-03-27 10:13:22 +00:00
|
|
|
printf("CHYBA\n");
|
2022-03-27 13:02:35 +00:00
|
|
|
}*/
|
2022-03-27 10:13:22 +00:00
|
|
|
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 13:35:56 +00:00
|
|
|
vysledok=(round(vysledok*100))/100;
|
|
|
|
if (vysledok2-vysledok < 0.0000001 && vysledok2-vysledok > -0.0000001){
|
2022-03-27 13:23:37 +00:00
|
|
|
printf("OK\n");
|
2022-03-27 10:13:22 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
printf("ZLE\n");
|
|
|
|
}
|
2022-03-27 13:19:33 +00:00
|
|
|
}
|
2022-03-27 12:48:13 +00:00
|
|
|
// printf("%.3f\n", vysledok);
|
2022-03-27 10:13:22 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|