ha_2/src/stack.c
int push(double value)
{
	// return the exit code:
	//	0 - success
	//	1 - not enough free space in the stack
	//  2 - other
	
	// the stack size is 50 elements
	
	if (count == MAX_SIZE) {
		printf("%s\n", "The stack is full.");
		return 1;
	}
	else if (count == MIN_SIZE) {
		stack = malloc(sizeof(struct Node));
		stack->prev = NULL;
		stack->next = NULL;
		stack->value = value;
		++count;
	}
	else {
		struct Node *temp = malloc(sizeof(struct Node));
		temp->value = value;
		temp->next = NULL;
		temp->prev = stack;
		stack->next = temp;
		stack = temp;
		++count;
	}
	if (stack->value != value || count < 0 || count > 50)
	return 2;
	return 0;
}
// it is your stack to work with it
it is your stack to work with it
it is your stack to work with it
int push(double value)
{
	if (count == MAX_SIZE) {
		printf("%s\n", "The stack is full.");
		return 1;
	}
	else if (count == MIN_SIZE) {
		stack = malloc(sizeof(struct Node));
		stack->prev = NULL;
		stack->next = NULL;
		stack->value = value;
		++count;
	}
	else {
		struct Node *temp = malloc(sizeof(struct Node));
		temp->value = value;
		temp->next = NULL;
		temp->prev = stack;
		stack->next = temp;
		stack = temp;
		++count;
	}
	if (stack->value != value || count < 0 || count > 50)
	return 2;
	return 0;
}
int push ( double value ) { if ( count == MAX_SIZE ) { printf ( " \n " , " " ) ; return 1 ; } else if ( count == MIN_SIZE ) { stack = malloc ( sizeof ( struct Node ) ) ; stack -> prev = NULL ; stack -> next = NULL ; stack -> value = value ; ++ count ; } else { struct Node * temp = malloc ( sizeof ( struct Node ) ) ; temp -> value = value ; temp -> next = NULL ; temp -> prev = stack ; stack -> next = temp ; stack = temp ; ++ count ; } if ( stack -> value != value || count < 0 || count > 50 ) return 2 ; return 0 ; }
it is your stack to work with it
it is your stack to work with it
// return the exit code: //	0 - success //	1 - not enough free space in the stack //  2 - other // the stack size is 50 elements