Update cv3/program.c

This commit is contained in:
Yurii Yakovenko 2024-10-14 19:58:34 +00:00
parent 411e43d1be
commit 60e3495099

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
////////@@@@@@@@@@@
#define STACK_SIZE 500
struct Stack
@ -48,7 +48,7 @@ int main()
struct Stack mystack;
mystack.size=0;
//memset(&mystack,0,sizeof(struct Stack));
int err=0;
char buf[505];
@ -73,7 +73,15 @@ int main()
{
case '+': rez=op1+op2; break;
case '-': rez=op1-op2; break;
case '/': rez=op1/op2; break;
case '/':
if(c=='/' && op2==0)
{
err=1;
printf("division_by_zero\n");
}
else
rez=op1/op2;
break;
case '*': rez=op1*op2; break;
} //p
}
@ -81,15 +89,17 @@ int main()
{
rez=atof(buf);
}
push_stack(&mystack, rez);
//printf(" %.2f\n", rez);
print_stack(&mystack);
if(!err)
{
push_stack(&mystack, rez);
//printf(" %.2f\n", rez);
print_stack(&mystack);
}
}
}while(1);
printf("no input\n");
if(!err)
printf("no input\n");
return 0;
}