diff --git a/du4/program b/du4/program index dce0973..f2a08ae 100755 Binary files a/du4/program and b/du4/program differ diff --git a/du4/program.c b/du4/program.c index b4daee9..ea1a107 100644 --- a/du4/program.c +++ b/du4/program.c @@ -1,14 +1,12 @@ #include -#include int main(){ - int c[2]; + int c[999]; int a, i = 0; int vysledok; char riadok[999]; char *endptr = NULL; - bool first = true; - bool second = false; + char need; while(1){ a++; char* r = fgets(riadok,999,stdin); @@ -17,38 +15,34 @@ int main(){ }else if(*r == ' ') continue; else if(*r == '+'){ - first = true; - second = true;; + need = *r; continue; }else if(*r == '-'){ - first = false; - second = false; + need = *r; continue; }else if(*r == '/'){ - first = true; - second = false; + need = *r; continue; }else if(*r == '*'){ - first = false; - second = true; + need = *r; continue; }else{ - float v = strtod(riadok,&endptr); + int v = strtod(riadok,&endptr); c[i++] = v; continue; } } - if(first == true && second == true) + if(need == '+') vysledok = c[0] + c[1]; - else if(first == false && second == false) + else if(need == '-') vysledok = c[0] - c[1]; - else if(first == true && second == false) + else if(need == '/') vysledok = c[0] / c[1]; - else if(first == false && second == true) + else if(need == '*') vysledok = c[0] * c[1]; - if(vysledok == c[2]) + if(vysledok == c[i]) printf("OK\n"); else printf("ZLE\n"); return 0; -} \ No newline at end of file +}