Обновить cv3/program.c

This commit is contained in:
Yevhen Kozirovskyi 2024-10-17 17:59:56 +00:00
parent 80f7810cf7
commit 3acee80c88

View File

@ -26,7 +26,7 @@ int isFull(StEk* stek) {
void push(StEk* stek, double chislo) { void push(StEk* stek, double chislo) {
if (isFull(stek)) { if (isFull(stek)) {
printf("full stack\n"); printf("full stack\n");
exit(1); return;
} }
stek->chisla[stek->vershina] = chislo; stek->chisla[stek->vershina] = chislo;
stek->vershina++; stek->vershina++;
@ -35,7 +35,7 @@ void push(StEk* stek, double chislo) {
double pop(StEk* stek) { double pop(StEk* stek) {
if (isEmpty(stek)) { if (isEmpty(stek)) {
printf("not enough operands\n"); printf("not enough operands\n");
exit(1); return 0;
} }
return stek->chisla[--stek->vershina]; return stek->chisla[--stek->vershina];
} }
@ -61,6 +61,7 @@ int main() {
if (c == '\n' && *bufer != '\n' && *bufer != ' ') { if (c == '\n' && *bufer != '\n' && *bufer != ' ') {
push(&stek, chislo); push(&stek, chislo);
} else if (c == '+' || c == '-' || c == '*' || c == '/') { } else if (c == '+' || c == '-' || c == '*' || c == '/') {
if (isEmpty(&stek)) { if (isEmpty(&stek)) {
printf("not enough operands\n"); printf("not enough operands\n");