This commit is contained in:
Damián Korpesio 2021-10-20 10:51:31 +02:00
parent bcd1368dbf
commit 6eb525c34d

View File

@ -21,11 +21,11 @@ int main() {
while (fgets(line, LINESIZE, stdin)) {
velkost = strlen(line);
if (velkost == 1 && line[velkost - 1] == '\n') {
printf("no input\n");
break;
}
if (input >= 10){
printf("no input\n");
break;
}
if (line[0] == '+' || line[0] == '-' || line[0] == '*' || line[0] == '/') {
@ -43,9 +43,14 @@ int main() {
a--;
}
if (line[0] == '/') {
number[a - 2].cislo = number[a - 2].cislo / number[a - 1].cislo;
a--;
}
if (number[a - 1].cislo == 0){
printf("division by zero");
}
else {
number[a - 2].cislo = number[a - 2].cislo / number[a - 1].cislo;
a--;
}
}
}
else {
p = atof(line);