aaaaaaaaaaaaaaaaaaaa
This commit is contained in:
parent
448b98b879
commit
bd21b7fecb
@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#define STACK_SIZE 50
|
||||
#define STACK_SIZE 10
|
||||
|
||||
struct stack
|
||||
{
|
||||
@ -11,11 +11,16 @@ struct stack
|
||||
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);
|
||||
stack->values[stack->size] = num;
|
||||
stack->size++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float getnpop(struct stack* stack)
|
||||
@ -103,7 +108,12 @@ int main(int argc, char const *argv[])
|
||||
if(!check_op(buf[0]))
|
||||
{
|
||||
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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user