Example #1
0
int main(int argc,char* argv[])
{
	struct node *first = NULL;
	struct node *last = NULL;
	struct node *p;

	if ( (first = create_node()) == NULL )
	{
		return 0;
	}

	if ( (first = add_to_node( first, 0)) == NULL )
	{
		printf("add false!\n"); 
	}
	last = first;

	if ( (first = add_to_node( first, 0)) == NULL )
	{
		printf("add false!\n"); 
	}

	if ( (first = add_to_node( first, 1)) == NULL )
	{
		printf("add false!\n"); 
	}

	if ( (first = add_to_node( first, 2)) == NULL )
	{
		printf("add false!\n"); 
	}

	if ( (first = add_to_node( first, 3)) == NULL )
	{
		printf("add false!\n"); 
	}

	first = delete_node(first);

	p = first;
	while( p != NULL )
	{
		printf("%d,",p->value);
		p = p->next;
	}
	printf("\b\n");

	p = last;
	while( p != NULL )
	{
		printf("%d,",p->value);
		p = p->prev;
	}
	printf("\b\n");

	return 0;
}
Example #2
0
int main(int argc,char* argv[])
{
		struct node *first = NULL;
		struct node *last = NULL;
		struct node *p = NULL;

		if ( (first = create_node()) == NULL )
		{
				return 0;
		}

		if ( (first = add_to_node( first, 0)) == NULL )
		{
				printf("add false!\n"); 
		}
		last = first;

		if ( (first = add_to_node( first, 0)) == NULL )
		{
				printf("add false!\n"); 
		}

		if ( (first = add_to_node( first, 1)) == NULL )
		{
				printf("add false!\n"); 
		}

		if ( (first = add_to_node( first, 2)) == NULL )
		{
				printf("add false!\n"); 
		}

		if ( (first = add_to_node( first, 3)) == NULL )
		{
				printf("add false!\n"); 
		}

		first = delete_node(first);

		
		show(first);
		
		printf("\b\n");
		
		show(last);

		printf("\b\n");

		return 0;
}