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