#include<stdio.h>
#include<stdlib.h>
struct node
{
int val;
struct node *next;
}*start=NULL,*temp=NULL;
void display()
{
//struct node *temp;
while(start->next!=NULL)
{
//temp=start;
start=start->next;
for(temp=start;temp!=NULL;temp=temp->next)
{ //printf("%d",temp->val);
if(temp->next!=NULL)
temp->next=temp->next->next;
//printf("start%d",start->val);
}
}
printf("%d",start->val);
}
/*void display1()
{
for(temp=start;temp!=NULL;temp=temp->next)
{
printf("%d",temp->val);
}
}*/
void input()
{
int i,a[100],n,b,k;
struct node *newnode;
printf("Test case??\n");
scanf("%d",&n);
printf("values???");
for(i=0;i<n;i++)
{
printf("%d",i);
scanf("%d",&a[i]);
}
for(k=0;k<n;k++)
{
for(i=1;i<=a[k];i++)
{
newnode=(struct node*)malloc(sizeof(struct node));
newnode->val=i;
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
temp=start;
//start->next=NULL;
}
else
{
temp->next=newnode;
temp=newnode;
//temp->next=NULL;
}
}display();
}
}
int main()
{
int n;
//printf("Values??\n");
input();
//display();
return 0;
}
The above is the code for the problem titled odd.I get the output when the test case is 1.Otherwise I dont get it.I cant find the reason