Exemplo n.º 1
0
void alternatingsplitinrev(struct node* src, struct node** aref, struct node** bref)
{
	struct node* a = NULL;
	struct node* b = NULL;
	struct node* cur = src;

	while(cur != NULL)
	{
		movenode(&cur, &a);
		if(cur != NULL)
			movenode(&cur, &b);
	}
	*aref = a;
	*bref = b;
}
Exemplo n.º 2
0
void testmovenode()
{
	struct node* node = NULL;
	node = buildlistinsortedorder(5);
	printlist(node, "node");
	struct node* temp = buildlistinsortedorder(5);
	printlist(temp, "temp");
	movenode(&node, &temp);
	printlist(node, "node");
	printlist(temp, "temp");
}
Exemplo n.º 3
0
void alternatingsplit(struct node* src, struct node** aref, struct node** bref)
{
	struct node dummya;
	dummya.next = NULL;
	struct node* a = &dummya;
	
	struct node dummyb;
	dummyb.next = NULL;
	struct node* b = &dummyb;

	struct node* cur = src;
	while(cur != NULL)
	{
		movenode(&cur, &(a->next));
		a = a->next;
		if(cur != NULL)
		{
			movenode(&cur, &(b->next));
			b = b->next;
		}
	}
	*aref = dummya.next;
	*bref = dummyb.next;
}
Exemplo n.º 4
0
main()
{
	struct node *a = NULL;
	struct node *b =NULL;
	push(&a,2);
	push(&a,1);
	push(&b,4);
	push(&b,3);
//	printf("%d\n",a->n);
	print(a);
	print(b);
	movenode(&a,&b);
	print(a);
	print(b);
	
}