#include <stdio.h>
struct node {
int value;
struct node *next;
};
void rearrange(struct node *list) {
struct node *p, *q;
int temp;
printf("%d\n",!list);
printf("%p\n",list);
printf("%p\n",list->next);
printf("%d\n",!list->next);
if (!list || !list -> next) return;
p = list; q = list -> next;
while(q) {
temp = p -> value; p->value = q -> value;
q->value = temp; p = q ->next;
q = p? p ->next : 0;
} 
printf("%p\n",p);
printf("%p\n",q);
}

int main(void) {
	// your code goes here
	struct node n1[7];
	int i;
	for(i=0;i<7;i++)
	{
		n1[i].value = i+1;
		if(i==6)
		n1[i].next = 0;
		else
		n1[i].next = &n1[i+1];
	}
	
	rearrange(&n1);
	
	for(i=0;i<7;i++){
		printf("\n%d",n1[i].value);
	}
	return 0;
}
