Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/old/
Upload File :
Current File : /var/www/html/venkat/old/iit2015140__4.c

#include<stdio.h>

struct node{
		int data;
		struct node * next;
	   };
int main()
{
	int n,i,a[n+1];
	struct node * head,* temp,* temp1;
	head = NULL;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{	scanf("%d",&a[i]);
	}
	temp1 = (struct node *) malloc (sizeof(struct node ));
	head = temp1 ;
	temp1->data = a[1];
	for(i=2;i<=n;i++)
	{
		temp = (struct node *) malloc(sizeof(struct node ));
		temp1->next = temp;
		temp->data = a[i];
		printf("%d",temp->data);
		temp1 = temp;
		temp = NULL;
	}
	temp1->next = NULL;
	temp = head;
	for(i=1;i<=n;i++)
	{ 	printf("%d",temp->data);
		printf("-");
	 	temp=temp->next;
	}
	temp=head;	
	temp1 = NULL;
	head = temp->next;
	temp=head;
	
	for(i=2;i<=n;i++)
	
	{
		
		if(i%2==0)
		{
			temp1 = temp->next;
	 		temp->next = temp1->next;
			temp=temp->next;
		}
		else
			temp1=NULL;
	}
	temp=head;
	for(i=1;temp!=NULL;i++)
	{
		printf("%d",temp->data);
		printf("-");
		temp=temp->next;
	}
	return 0;
}