C++ Programs






1. SINGLY LINKED LIST







#include<iostream>
using namespace std;
struct node
{
int data;
node *next;
};
class singlyll
{
node *start, *last, *head;
public:
void insertfirst();
void insertlast();
void insertloc();
void deletefirst();
void deletelast();
void deleteloc();
void display();
singlyll()
{
start=last=NULL;
}
};
void singlyll::insertfirst()
{
head=new node;
cout<<"Enter the value:";
cin>>head->data;
if(start==NULL)
{
head->next=NULL;
start=last=head;
}
else
{
head->next=start;
start=head;
}
}
void singlyll::insertlast()
{
head=new node;
cout<<"Enter the value:";
cin>>head->data;
head->next=NULL;
if(start==NULL)
{
start=last=head;
}
else
{
last->next=head;
last=head;
}
}
void singlyll::insertloc()
{
int pos;
node *temp,*prev;
cout<<"\n Enter the position:";
cin>>pos;
if(pos==1)
{
insertfirst();
}
else
{
head=new node;
cout<<"Enter the value:";
cin>>head->data;
temp=start;
for(int i=1;i<pos;i++)
{
if(temp!=NULL)
{
prev=temp;
temp=temp->next;
}
else
{
head->next=NULL;
last->next=head;
last=head;
}
}
prev->next=head;
head->next=temp;
if(temp==NULL)
last=head;
}
}
void singlyll::deletefirst()
{
if(start==NULL)
cout<<"\n The list is empty\n";
else
{
node *temp=start;
cout<<"\n The deleted item is "<<start->data;
if(start==last)
{
start=last=NULL;
}
else
{
start=start->next;
}
delete temp;
}
}
void singlyll::deletelast()
{
if(start==NULL)
cout<<"\n The list is empty\n";
else
{
cout<<"\n The deleted item is "<<start->data;
if(start==last)
{
start=last=NULL;
}
else
{
node *temp=start;
while(temp->next!=last)
{
temp=temp->next;
temp->next=NULL;
}
delete temp;
last=temp;
}
}
}
void singlyll::deleteloc()
{
if(start==NULL)
cout<<"\n The list is empty\n";
else
{
node *temp,*prev;
int pos;
cout<<"\n Enter the position:";
cin>>pos;
if(pos==1)
deletefirst();
else
{
temp=start;
for(int i=1;i<pos;i++)
{
prev=temp;
temp=temp->next;
}
if(temp!=NULL)
{
if(temp==last)
{
last=prev;
}
prev->next=temp->next;
cout<<"\n The deleted item is"<<temp->data;
delete temp;
}
else
{
cout<<"\n No data is deleted";
}
}
}
}
void singlyll::display()
{
node *temp;
temp=start;
if(temp==NULL)
{
cout<<"\n List is empty";
}
else
{
cout<<"\n The elements are:\n";
while(temp!=NULL)
{
cout<<temp->data;
cout<<"\t";
temp=temp->next;}
}
}
int main()
{
singlyll s;
int ch;
char c;
do
{
cout<<"\n1 Insert first"<<"\n2 Insert last"<<"\n3 Insert at location"<<"\n4 Delete first"<<"\n5 Delete last"<<"\n6 Delete at position"<<"\n7 Display";
cout<<"\n Enter your choice:";
cin>>ch;
switch(ch)
{
case 1:
s.insertfirst();
break;
case 2:
s.insertlast();
break;
case 3:
s.insertloc();
break;
case 4:
s.deletefirst();
break;
case 5:
s.deletelast();
break;
case 6:
s.deleteloc();
break;
case 7:
s.display();
break;
default:
cout<<"\n Invalid choice";
}
cout<<"\n Do you want to continue(y/Y):";
cin>>c;
}
while((c=='y')||(c=='Y'));
return 0;
}


2. DOUBLLY LINKED LIST







#include<iostream>
using namespace std;
struct node
{
int data;
node *prev;
node *next;
node *pre;
};
class doublyll
{
node *start,*last,*head;
public:
void insertfirst();
void insertlast();
void insertpos();
void deletefirst();
void deletelast();
void deletepos();
void display();
doublyll()
{
start=last=NULL;
}
};
node *next,*prev;
void doublyll::insertfirst()
{
head=new node;
cout<<"\nEnter the no:";
cin>>head->data;
head->next=NULL;
head->prev=NULL;
if(start==NULL)
start=last=head;
else
{
head->next=start;
start=head;
}
}
void doublyll::insertlast()
{
head=new node;
cout<<"\nEnter the no:";
cin>>head->data;
head->next=NULL;
head->prev=NULL;
if(start==NULL)
{
start=last=head;
}
else
{
head->prev=last;
last->next=head;
last=head;
}
}
void doublyll::insertpos()
{
int pos;
node *temp,*pre;
cout<<"\nEnter position:";
cin>>pos;
if(pos==1)
insertfirst();
else
{
head=new node;
cout<<"\nEnter no:";
cin>>head->data;
temp=start;
for(int i=1;i<pos;i++)
{
if(temp!=NULL)
{
pre=temp;
temp=temp->next;
}
else
{
head->next=NULL;
last->next=head;
head->pre=last;
last=head;
}
}
pre->next=head;
head->prev=pre;
head->next=temp;
temp->prev=head;
if(temp==NULL)
last=head;
}
}
void doublyll::deletefirst()
{
if(start==NULL)
cout<<"\nThe list is empty\n";
else
{
node *temp=start;
cout<<"\nThe deleted item is "<<start->data;
if(start==last)
start=last=NULL;
else
start=start->next;
start->prev=NULL;
delete temp;
}
}
void doublyll::deletelast()
{
if(start==NULL)
cout<<"\nThe list is empty\n";
else
{
cout<<"\nThe deleted item is"<<last->data;
if(start==last)
start=last=NULL;
else
{
node *temp;
temp=start;
while(temp->next!=last)
temp=temp->next;
temp->next=NULL;
delete last;
last=temp;
}
}
}
void doublyll::deletepos()
{
if(start==NULL)
cout<<"\nThe list is empty\n";
else
{
node *temp,*pre;
cout<<"\nEnter position:";
int pos;
cin>>pos;
if(pos==1)
deletefirst();
else
{
temp=start;
for(int i=1;i<pos;i++)
{
pre=temp;
temp=temp->next;
}
if(temp!=NULL)
{
if(temp==last)
last=pre;
pre->next=temp->next;
temp->next->prev=pre;
cout<<"\nThe deleted item is "<<temp->data;
delete temp;
}
else
cout<<"\nNo data deleted\n";
}
}
}
void doublyll::display()
{
node *temp,*pre;
cout<<"\n Forward traversal\n";
temp=start;
while(temp!=NULL)
{
cout<<temp->data<<"\t";
temp=temp->next;
}
cout<<"\n Reverse traversal\n";
pre=last;
while(pre!=NULL)
{
cout<<pre->data<<"\t";
pre=pre->prev;
}
}
int main()
{
doublyll d;
int choice;
char ch;
do
{
cout<<"\n 1.insert first \n 2.insert last \n 3.insert pos \n 4.delet first \n 5.delet last\n 6.delet pos \n 7.display";
cout<<"\nEnter your choice:";
cin>>choice;
switch(choice)
{
case 1:d.insertfirst();
break;
case 2:d.insertlast();
break;
case 3:d.insertpos();
break;
case 4:d.deletefirst();
break;
case 5:d.deletelast();
break;
case 6:d.deletepos();
break;
case 7:d.display();
break;
}
cout<<"\n Do u want to continue?(y/Y):";
cin>>ch;
}while(ch=='Y'||ch=='y');
return 0;
}


3. STACK USING SINGLY LINKED LIST










#include<iostream>
using namespace std;
struct node
{
int data;
node *next;
};
class stacksll
{
node *start,*last,*head;
public:
void push();
void pop();
void display();
stacksll()
{
start=last=NULL;
}
};
void stacksll :: push()
{
head=new node;
cout<<"enter the data \n";
cin>>head->data;
if(start==NULL)
{
head->next=NULL;
start=last=head;
}
else
{
head->next=start;
start=head;
}
}
void stacksll:: pop()
{
if(start==NULL)
cout<<"list is empty \n";
else
{
node *temp=start;
cout<<"deleted item is"<<start->data;
if(start==last)
start=last=NULL;
start=start->next;
delete temp;
}
}
void stacksll :: display()
{
node *temp;
temp=start;
if(temp==NULL)
cout<<"stack is empty";
else
cout<<"stack elements are :\n";
while (temp!=NULL)
{
cout<<temp->data<<"\n";
temp=temp->next;
}
}
int main()
{
int c;
char ch;
stacksll s;
do
{
cout<<"1. push \n 2.pop \n 3.display \n";
cout<<"enter your choice";
cin>>c;
switch(c)
{
case 1:s.push();
break;
case 2:s.pop();
break;
case 3:s.display();
break;
default:
cout<<"invalid choice\n";
}
cout<<"\n do you want to continue?(y/n)\n";
cin>>ch;
}
while((ch='Y')||(ch='y'));
return(0);
}

 

4. QUEUE USING LINKED LIST







#include<iostream>
using namespace std;
struct node
{
int data;
node *next;
};
class queuell
{
node *start, *last, *head;
public:
void insert();
void delet();
void display();
queuell()
{
start=last=NULL;
}
};
void queuell::insert()
{
head=new node;
cout<<"Enter the value:";
cin>>head->data;
head->next=NULL;
if(start==NULL)
{
start=last=head;
}
else
{
last->next=head;
last=head;
}
}
void queuell::delet()
{
if(start==NULL)
cout<<"\n The queue is empty\n";
else
{
node *temp=start;
cout<<"\n The deleted item is "<<start->data;
if(start==last)
{
start=last=NULL;
}
else
{
start=start->next;
}
delete temp;
}
}
void queuell::display()
{
node *temp;
temp=start;
if(temp==NULL)
{
cout<<"\n stack is empty";
}
else
{
cout<<"\n The linked queue elements are:\n";
while(temp!=NULL)
{
cout<<temp->data;
cout<<"\t";
temp=temp->next;
}
}
}
int main()
{
queuell s;
int ch;
char c;
do
{
cout<<"\n1 Insert"<<"\n2 Delete"<<"\n3 Display";
cout<<"\n Enter your choice:";
cin>>ch;
switch(ch)
{
case 1:
s.insert();
break;
case 2:
s.delet();
break;
case 3:
s.display();
break;
default:
cout<<"\n Invalid choice";
}
cout<<"\n Do you want to continue(y/Y):";
cin>>c;
}
while((c=='y')||(c=='Y'));
return 0;
}

 

5. POLYNOMIAL ADDITION USING LINKED LIST









#include<iostream>
using namespace std;
struct poly
{
int coeff;
int exp;
poly *next;
};
class polylist
{
poly *start,*last;
public:
void read();
void display();
void sort();
polylist()
{
start=last=NULL;
}
void insertnode(poly*);
polylist operator+(polylist);
};
void polylist::read()
{
int i=0,c,e;
poly *head;
while(1)
{
i++;
cout<<"\nEnter the coefficient & exponent of the term "<<i<<":";
cin>>c>>e;
if(c==-1)
break;
else
{
head=new poly;
head->coeff=c;
head->exp=e;
head->next=NULL;
if(start==NULL)
start=last=head;
else
{
last->next=head;
last=head;
}
}
}
}
void polylist::display()
{
poly *temp=start;
do
{
cout<<temp->coeff<<" x^ "<<temp->exp;
if(temp->next!=NULL)
cout<<" + ";
temp=temp->next;
}
while(temp!=NULL);
}
polylist polylist::operator+(polylist p2)
{
polylist p3;
poly *t1,*t2,*t3;
t1=start;
t2=p2.start;
while((t1!=NULL)&&(t2!=NULL))
{
t3=new poly;
if(t1->exp > t2->exp)
{
t3->coeff=t1->coeff;
t3->exp=t1->exp;
t3->next=NULL;
t1=t1->next;
}
else if(t1->exp < t2->exp)
{
t3->coeff=t2->coeff;
t3->exp=t2->exp;
t3->next=NULL;
t2=t2->next;
}
else
{
t3->coeff=t1->coeff+t2->coeff;
t3->exp=t1->exp;
t3->next=NULL;
t1=t1->next;
t2=t2->next;
}
p3.insertnode(t3);
}
while(t1!=NULL)
{
t3=new poly;
t3->coeff=t1->coeff;
t3->exp=t1->exp;
t3->next=NULL;
t1=t1->next;
p3.insertnode(t3);
}
while(t2!=NULL)
{
t3=new poly;
t3->coeff=t2->coeff;
t3->exp=t2->exp;
t3->next=NULL;
t2=t2->next;
p3.insertnode(t3);
}
return p3;
}
void polylist::sort()
{
poly *t1,*t2;
int c,e;
for(t1=start;t1->next!=NULL;t1=t1->next)
{
for(t2=t1->next;t2->next!=NULL;t2=t2->next)
{
if(t1->exp < t2->exp)
{
c=t1->coeff;
e=t1->exp;
t1->coeff=t2->coeff;
t1->exp=t2->exp;
t2->coeff=c;
t2->exp=e;
}
}
}
}
void polylist::insertnode(poly *t3)
{
if(start==NULL)
start=last=t3;
else
{
last->next=t3;
last=t3;
}
}
int main()
{
polylist p1,p2,p3;
p1.read();
p1.sort();
cout<<"\n1st polynomial is :";
p1.display();
p2.read();
p2.sort();
cout<<"\n2nd polynomial is :";
p2.display();
p3=p1 + p2;
cout<<"\nThe resultant polynomial is :";
p3.display();
return 0;
}

 

6. BINARY  TREE






#include<iostream>
using namespace std;
struct node
{
int data;
node *left;
node *right;
};
class tree
{
node *root;
public:
void makeroot();
node *makenode(int);
void createtree(node*);
void inorder(node*);
void preorder(node*);
void postorder(node*);
};
void tree::makeroot()
{
int item;
cout<<"\n enter root data:";
cin>>item;
root=makenode(item);
createtree(root);
cout<<"\n Inorder traversal:";
inorder(root);
cout<<"\n preorder traversal:";
preorder(root);
cout<<"\n postorder traversal:";
postorder(root);
}
node *tree::makenode(int item)
{
node *head=new node;
head->data=item;
head->left=head->right=NULL;
return head;
}
void tree::createtree(node *root)
{
int ch,item;
cout<<"\n do u want to create a left child for"<<root->data<<"\n enter(0/1):";
cin>>ch;
if(ch==1)
{
cout<<"\n enter data:";
cin>>item;
root->left=makenode(item);
createtree(root->left);
}
cout<<"\n Do u want to create a right child for"<<root->data<<"\n enter(0/1):";
cin>>ch;
if(ch==1)
{
cout<<"\n Enter data:";
cin>>item;
root->right=makenode(item);
createtree(root->right);
}
}
void tree::inorder(node *root)
{
if(root!=NULL)
{
inorder(root->left);
cout<<root->data<<"\t";
inorder(root->right);
}
}
void tree::preorder(node *root)
{
if(root!=NULL)
{
cout<<root->data<<"\t";
preorder(root->left);
preorder(root->right);
}
}
void tree::postorder(node *root)
{
if(root!=NULL)
{
postorder(root->left);
postorder(root->right);
cout<<root->data<<"\t";
}
}
int main()
{
tree t;
t.makeroot();
return 0;
}

 


7. BINARY SEARCH TREE









#include<iostream>
using namespace std;
struct node
{
int data;
node *left,*right;
};
class Searchtree
{
int a[20];
public:
int n;
node *root;
void read();
void create();
node *makenode(int);
node *insert(node *,node *);
void inorder(node *);
void postorder(node *);
void preorder(node *);
node *search(int);
void deletion(int);
void deletnode(node *,node *);
Searchtree()
{
root=NULL;
}
};
void Searchtree :: read()
{
cout<<"\nEnter the elements:";
for(int i=0;i<n;i++)
{
cin>>a[i];
}
}
void Searchtree ::create()
{
node *head;
for(int i=0;i<n;i++)
{
head= makenode(a[i]);
root=insert(head,root);
}
cout<<"\nInorder Traversal:";
inorder(root);
cout<<"\nPreorder Traversal:";
preorder(root);
cout<<"\nPostorder Traversal:";
postorder(root);
}
node *Searchtree:: makenode(int item)
{
node *head = new node;
head->data=item;
head->left=head->right=NULL;
return head;
}
node *Searchtree ::insert(node *head,node *root)
{
if(root==NULL)
{
root=head;
}
else
{
if(head->data<root->data)
root->left=insert(head,root->left);
else
root->right=insert(head,root->right);
}
return root;
}
node *Searchtree :: search(int item)
{
node *ptr=root;
while (ptr->data!=item)
{
if(item<ptr->data)
ptr=ptr->left;
else
ptr=ptr->right;
if (ptr==NULL)
break;
}
return ptr;
}
void Searchtree :: deletion(int item)
{
node *ptr=root;
node *parent=NULL;
while(ptr->data!=item)
{
if(item<ptr->data)
{
parent=ptr;
ptr=ptr->left;
}
else
{
parent=ptr;
ptr=ptr->right;
}
if(ptr==NULL)
break;
}
if(ptr==NULL)
cout<<"|nItem doesnot exist";
else
deletnode(ptr,parent);
}
void Searchtree :: deletnode(node *ptr,node *parent)
{
if((ptr->left==NULL)&&(ptr->right==NULL))
{
if(ptr==root)
root=NULL;
else
{
if(parent->left==ptr)
parent->left=NULL;
else
parent->right=NULL;
}
delete ptr;
}
else if ((ptr->left!=NULL)&&(ptr->right!=NULL))
{
node *ptr1=ptr->right;
node *parent=ptr;
while(ptr1->left!=NULL)
{
parent=ptr1;
ptr1=ptr->left;
}
ptr->data=ptr1->data;
deletnode(ptr1,parent);
}
else
{
if(ptr==root)
{
if(ptr->left==NULL)
root=ptr->right;
else
root= ptr->left;
}
else
{
if(parent->left==ptr)
{
if(ptr->left==NULL)
parent->left=ptr->right;
else
parent->left=ptr->left;
}
else if(parent->right==ptr)
{
if(ptr->left==NULL)
parent->right=ptr->right;
else
parent->right=ptr->left;
}
}
delete ptr;
}
}
void Searchtree :: inorder(node *root)
{
if(root!=NULL)
{
inorder(root->left);
cout<<root->data<<"\t";
inorder(root->right);
}
}
void Searchtree :: preorder(node *root)
{
if(root!=NULL)
{
cout<<root->data<<"\t";
preorder(root->left);
preorder(root->right);
}
}
void Searchtree ::postorder(node *root)
{
if(root!=NULL)
{
postorder(root->left);
postorder(root->right);
cout<<root->data<<"\t";
}
}
int main()
{
Searchtree t;
cout<<"\nEnter the Total no of Nodes:";
cin>>t.n;
t.read();
t.create();
int ch,item;
node *head;
int choice;
do
{
cout<<"\nBinary Search Tree Operations:";
cout<<"\n1.Insertion of Nodes";
cout<<"\n2.Deletion of Nodes";
cout<<"\nBinary Searching for nodes";
cout<<"\nEnter your choice :";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nEnter the Number to be inserted:";
cin>>item;
head=t.makenode(item);
t.root=t.insert(head,t.root);
t.inorder(t.root);
break;
case 2:
cout<<"\nEnter the Number to be deleted:";
cin>>item;
t.deletion(item);
cout<<"\nInorder Traversal";
t.inorder(t.root);
case 3:
cout<<"\nEnter the Number to be searched:";
cin>>item;
node *ptr=t.search(item);
if(ptr==NULL)
cout<<"\nItem doesnot exist";
else
{cout<<"\nItem is present in the tree";}
break;
}
cout<<"\nDo you want to continue(press 1):";
cin>>choice ;
}
while(choice==1);
}

 

8. GRAPH






#include<iostream>
using namespace std;
class graph
{
int n,a[20][20],front,rear,v[20],q[20],s[20],top;
public:
void create();
void display();
void insert(int);
void delfront();
void BFS();
void DFS();
void push(int);
void pop();
graph()
{
front=rear=-1;
top=-1;
}
};
void graph::create()
{
cout<<"\nEnter no: of vertices:";
cin>>n;
int ch;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<"\nIs any edge from "<<i<<" to "<<j<<" Enter (0/1):";
cin>>ch;
if(ch==0)
a[i][j]=a[j][i]=0;
else
a[i][j]=a[j][i]=1;
}
}
}
void graph::display()
{
cout<<"\nAdjacency Matrix Representation is\n";
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<"\n";
}
}
void graph::BFS()
{
for(int i=1;i<=n;i++)
v[i]=0;
insert(1);
v[1]=1;
do
{
int i=q[front];
for(int j=1;j<=n;j++)
{
if((a[i][j]==1)&&(v[j]==0))
{
insert(j);
v[j]=1;
}
}
cout<<" "<<q[front];
delfront();
}
while(front!=-1);
}
void graph::delfront()
{
if(front==rear)
front=-1;
else
front++;
}
void graph::insert(int i)
{
rear++;
q[rear]=i;
if(front==-1)
front++;
}
void graph::DFS()
{
int i,j;
for(i=1;i<=n;i++)
v[i]=0;
v[1]=1;
push(1);
cout<<"1";
do
{
int i=s[top];
for(j=1;j<=n;j++)
{
if((a[i][j]==1)&&(v[j]==0))
{
v[j]=1;
push(j);
cout<<" "<<j;
break;
}
}
if(j==(n+1))
pop();
}
while(top!=-1);
}
void graph::push(int i)
{
top++;
s[top]=i;
}
void graph::pop()
{
top--;
}
int main()
{
graph g;
g.create();
g.display();
int ch;
char c;
do
{
cout<<"\nGraph Traversals";
cout<<"\n1.Breadth First Search (BFS)";
cout<<"\n2.Depth First Search (DFS)";
cout<<"\nEnter the choice:";
cin>>ch;
if(ch==1)
{
cout<<"\nBFS is";
g.BFS();
}
else if(ch==2)
{
cout<<"\n DFS is";
g.DFS();
}
else
cout<<"\nInvald choice";
cout<<"\nDo u want to continue(y/n):";
cin>>c;
}
while(c=='y'||c=='Y');
return 0;
}

 

9. SORTING






#include<iostream>
using namespace std;
class sort
{
int a[25],n,b[25];
public:
void read();
void display();
void interchange(int,int);
void bubble();
void quick();
void quicksort(int,int);
int partition(int,int);
void radix();
};
void sort::read()
{
cout<<"\nenter range:";
cin>>n;
cout<<"\nenter the numbers:";
for(int i=0;i<n;i++)
cin>>a[i];
}
void sort::display()
{
for(int i=0;i<n;i++)
cout<<a[i]<<"\t";
}
void sort::interchange(int i,int j)
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
void sort::bubble()
{
for(int i=0;i<n-1;i++)
{
for(int j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
interchange(j,j+1);
}
}
}
}
void sort::quick()
{
quicksort(0,n-1);
}
void sort::quicksort(int low,int high)
{
if(low<high)
{
int j=partition(low,high+1);
quicksort(low,j-1);
quicksort(j+1,high);
}
}
int sort::partition(int low,int high)
{
int v=low;
int k=a[low];
do
{
do
{
low++;
}while(a[low]<k);
do
{
high--;
}while(a[high]>k);
if(low<high)
interchange(low,high);
}while(low<high);
interchange(v,high);
return high;
}
void sort::radix()
{
int bucket[10][10],buck[10],i,j,k,l,num,div,large,passes;
div=1;
num=0;
large=a[0];
for(i=1;i<n;i++)
if(a[i]>large)
large=a[i];
while(large>0)
{
num++;
large=large/10;
}
for(passes=0;passes<num;passes++)
{
for(k=0;k<10;k++)
buck[k]=-1;
for(i=0;i<n;i++)
{
l=(a[i]/div)%10;
buck[l]++;
int rear=buck[l];
bucket[l][rear]=a[i];
}
i=0;
for(k=0;k<10;k++)
{
for(j=0;j<=buck[k];j++)
{
a[i]=bucket[k][j];
i++;
}
}
div=div*10;
}
}
int main()
{
sort s;
int ch,c;
s.read();
do
{
cout<<"\nMENU\n"<<"\n1.bubble sort "<<" \n2.quick sort "<<" \n3.radix sort";
cout<<"\nenter your choice:";
cin>>ch;
switch(ch)
{
case 1:s.bubble();
break;
case 2:s.quick();
break;
case 3:s.radix();
break;
default:
cout<<"\ninvalid choice";
break;
}
cout<<"\nsorted array is:\n";
s.display();
cout<<"\ndo u want to continue? (enter 0/1):";
cin>>c;
}while(c==1);
return 0;
}

0 comments:

Post a Comment