Professional Documents
Culture Documents
h>
struct node{
node* nextocome;
};
t->data=data;
t->nextocome=NULL;
if(head==NULL)
head=t;
last=t;
else{
last->nextocome=t;
last=t;
return head;
}
struct node * solve(struct node* head)
while(temparature!=NULL){
if(temparature->data%2==0) // if
element is even
// start-> 1 2 4 6 4 10 8 12 4 end-> 7 9
prepost=NULL;
start=temparature;
nextocome=temparature->nextocome;
temparature->nextocome=prepost;
prepost=temparature;
temparature=nextocome;
end=temparature;
start->nextocome=temparature;
if(p==NULL)
head=prepost;
else
p->nextocome=prepost;
else{
p=temparature;
temparature=temparature->nextocome;
return head;
while(temparature!=NULL)
cout<<temparature->data<<" ";
temparature=temparature->nextocome;
}
int main()
int linklist;
cin>>linklist;
for(int i=0;i<linklist;i++)
cin>>temparature;
head=insert(head,temparature);
head=solve(head);
display(head);
return 0;