case 0 is runtime error .Can u please tell me where i am wrong
#include <bits/stdc++.h>
using namespace std;
class node{
public:
int data;
nodenext;
node(int d){
data=d;
next=NULL;
}
};
void insert(node&head){
int data;
cin>>data;
node*n=new node(data);
node*temp=head;
if(head==NULL){
head=n;
}
else{
while(temp->next){
temp=temp->next;
}
temp->next=n;
}
}
void oddeven(node*&head,int n){
if(n<=1)return ;
nodetemp=head;
nodenewll=NULL;
nodepost=NULL;
nodeprepost;
while(temp){
if(temp->data&1){
if(newll==NULL){
head=newll=temp;
}
else{
newll->next=temp;
newll=newll->next;
}
}
else{
if(post==NULL)
prepost=post=temp;
else
{ post->next=temp;
post=post->next;
}
}
temp=temp->next;
}
newll->next=prepost;
post->next=NULL;
}
void printll(nodehead){
while(head){
cout<data<<" ";
head=head->next;
}
}
int main() {
int n;
cin>>n;
nodehead=NULL;
for(int i=0;i<n;i++){
insert(head);
}
oddeven(head,n);
printll(head);
}