77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <math.h>
|
||
|
||
|
||
|
||
int main() {
|
||
|
||
int i,j; // pro cyklus
|
||
double number1, number2, summary, rsum, msum; /*aby se mohlo poèítat s desetinnými èísly*/
|
||
char operand, equ; //naèítání znakù
|
||
|
||
scanf("%lf", &number1); // nacte prvni cislo, znamenko, druhe cislo
|
||
scanf("%c", &operand);
|
||
scanf("%lf", &number2);
|
||
scanf("%c", &equ);
|
||
scanf("%lf",&msum);
|
||
|
||
|
||
/*pokud se operand rovna deleni a delitel se rovna nule vypise chybu*/
|
||
if((operand == '/') && (number2 == 0)){
|
||
printf("Nulou sa nedá deli<6C>");
|
||
}
|
||
if(operand !='+' && operand !='-' && operand !='*' && operand !='/'){
|
||
return 1;
|
||
printf("\n");
|
||
}
|
||
if(equ !='='){
|
||
return 1;
|
||
printf("\n");
|
||
|
||
}
|
||
|
||
else if(operand=='+'){
|
||
rsum=number1+number2;
|
||
if(msum==rsum){
|
||
printf("OK\n");
|
||
}
|
||
else{
|
||
printf("ZLE\n");
|
||
}
|
||
printf("%lf\n",rsum);
|
||
}
|
||
else if(operand=='-'){
|
||
rsum=number1-number2;
|
||
if(msum==rsum){
|
||
printf("OK\n");
|
||
}
|
||
else{
|
||
printf("ZLE\n");
|
||
}
|
||
printf("%lf\n",rsum);
|
||
}
|
||
else if(operand=='*'){
|
||
rsum=number1*number2;
|
||
if(msum==rsum){
|
||
printf("OK\n");
|
||
}
|
||
else{
|
||
printf("ZLE\n");
|
||
}
|
||
printf("%lf\n",rsum);
|
||
}
|
||
else if(operand=='/'){
|
||
rsum=number1/number2;
|
||
if(msum==rsum){
|
||
printf("OK\n");
|
||
}
|
||
else{
|
||
printf("ZLE\n");
|
||
}
|
||
printf("%lf\n",rsum);
|
||
}
|
||
}
|
||
|