diff --git a/EvenAfterOdd-LinkedList.cpp b/EvenAfterOdd-LinkedList.cpp new file mode 100644 index 0000000..94907b0 --- /dev/null +++ b/EvenAfterOdd-LinkedList.cpp @@ -0,0 +1,98 @@ +#include +using namespace std; +class node{ +public: + int data; + node * next; + node(int data){ + this->data=data; + this->next=NULL; + } +}; +node* arrange_LinkedList(node* head) +{ + + node*oh=NULL; + node*ot=NULL; + node*eh=NULL; + node*et=NULL; + while(head!=NULL) + { + if((head->data)%2!=0) + { + if(oh==NULL) + { + oh=head; + ot=head; + } + else + { ot->next=head; + ot=head; + } + } + else + { + if(eh==NULL) + { + eh=head; + et=head; + } + else + { + et->next=head; + et=head; + } + } + head=head->next; + } + + if(oh==NULL) + { et=NULL; + return eh; + } + if(eh==NULL) + { + ot=NULL; + return oh; + } + et=NULL; + ot->next=eh; + return oh; + +} + +node* takeinput(){ + int data; + cin>>data; + node* head=NULL,*tail=NULL; + while(data!=-1){ + node *newnode=new node(data); + if(head==NULL) { + head=newnode; + tail=newnode; + } + else{ + tail->next=newnode; + tail=newnode; + } + cin>>data; + } + return head; +} +void print(node *head) +{ + node*temp=head; + while(temp!=NULL) + { + cout<data<<" "; + temp=temp->next; + } + cout< +using namespace std; +void towerOfHanoi(int n, char source, char auxiliary, char destination) { + + if(n==0) + return; + towerOfHanoi(n-1, source, destination, auxiliary); + cout<> n; + towerOfHanoi(n, 'a', 'b', 'c'); +} \ No newline at end of file