21
This commit is contained in:
parent
b476296374
commit
08f0f63542
@ -33,7 +33,7 @@ float calculator(float n1, float n2, char operation) {
|
|||||||
return n1 / n2;
|
return n1 / n2;
|
||||||
} else {
|
} else {
|
||||||
printf("division by zero\n");
|
printf("division by zero\n");
|
||||||
exit(1);
|
return n1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -63,11 +63,9 @@ void print_stack() {
|
|||||||
}
|
}
|
||||||
printf("%.2f", stack[i]);
|
printf("%.2f", stack[i]);
|
||||||
}
|
}
|
||||||
printf(" \n"); // добавляем пробел перед новой строкой
|
printf(" \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char arr[50];
|
char arr[50];
|
||||||
char *pend;
|
char *pend;
|
||||||
@ -93,7 +91,9 @@ int main() {
|
|||||||
float n1 = pop();
|
float n1 = pop();
|
||||||
char operation = arr[0];
|
char operation = arr[0];
|
||||||
float result = calculator(n1, n2, operation);
|
float result = calculator(n1, n2, operation);
|
||||||
push(result);
|
if (!(operation == '/' && n2 == 0)) {
|
||||||
|
push(result);
|
||||||
|
}
|
||||||
print_stack();
|
print_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user