Your IP : 216.73.216.40


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

#include<stdio.h>
#include<stdlib.h>
struct node
{
	int data;
	struct node * next;
};
struct node *new_node()
{
	struct node *p;
	p=(struct node *)malloc(sizeof(struct node));
	scanf("%d",&(p->data));
	p->next=NULL;
	return p;
};
void delete(struct node *head,struct node *pt)
{
	struct node *start, *p, *temp;
	start=head;
	p=pt;
	temp=start;
	while(temp->next!=p)
		temp=temp->next;
	temp->next=p->next;
	p->next=NULL;
}
int main(void)
{
	int n,i;
	scanf("%d",&n);
	struct node *start, *p;
	p=(struct node *)malloc(sizeof(struct node));
	start=(struct node *)malloc(sizeof(struct node));
	start=p;
	p->next=NULL;
	scanf("%d",&(p->data));
	for(i=1;i<n;i++)
	{
		p->next=new_node();
	}	
	p=start;
	printf("%d",p->data);
	while((p->next)!=NULL)
	{
		p=p->next;
		printf("-%d",(p->data));
	}
	printf("\n");
	p=start;
	while(p!=NULL)
	{
		if(((p->data)%2)!=0) delete(start,p);
		p=p->next;
	}
	p=start;
	printf("%d",p->data);
	while((p->next)!=NULL)
	{
		p=p->next;
		printf("-%d",(p->data));
	}
	printf("\n");
	return 0;
}