aaaaaaaaaaaaaaaaaaaa

This commit is contained in:
Ivan Leichenko 2024-10-14 15:56:30 +02:00
parent 448b98b879
commit bd21b7fecb

View File

@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#define STACK_SIZE 50 #define STACK_SIZE 10
struct stack struct stack
{ {
@ -11,11 +11,16 @@ struct stack
int size; int size;
}; };
void add(struct stack* stack, float num) int add(struct stack* stack, float num)
{ {
if(stack->size == STACK_SIZE)
{
return 1;
}
assert(stack->size < STACK_SIZE); assert(stack->size < STACK_SIZE);
stack->values[stack->size] = num; stack->values[stack->size] = num;
stack->size++; stack->size++;
return 0;
} }
float getnpop(struct stack* stack) float getnpop(struct stack* stack)
@ -103,7 +108,12 @@ int main(int argc, char const *argv[])
if(!check_op(buf[0])) if(!check_op(buf[0]))
{ {
num = atof(buf); num = atof(buf);
add(&calc_stack, num); int add_code = add(&calc_stack, num);
if(add_code == 1)
{
printf("full stack\n");
return 0;
}
} }
else else
{ {