Tue Sep 06, 2011 10:55 am
#include<iostream>
using namespace std;
class set
{
int data[10];
int size;
public:
set &a(){size=0;}
set &b() {size=0;}
int getsize() {return size;}
void printset()
{
int i;
for(i=0;i<size;i++)
cout<<data[i]<<endl;
}
void insertbegning(int data)
{
int i;
for(i=size;i>=0;i--)
this->data[i+1]=this->data[i];
this-> data[0]=data;
size=size+1;
}
void unionof()
{ set c;
int i,j;
while(i!=0||j!=0)
while(j!=0)
{
if(i==j)
c.insertbegning(data[j]);
else
c.insertbegning(data[i]);
c.insertbegning(data[j]);
}
}
};
int main()
{
set a;
set b;
set c;
set d;
cout<<a.getsize();
cout<<b.getsize();
a.printset();
b.printset();
a.insertbegning(40);
a.insertbegning(30);
a.insertbegning(20);
a.insertbegning(10);
b.insertbegning(20);
b.insertbegning(30);
b.insertbegning(50);
b.insertbegning(60);
cout<<"the content of list a";
cout<<"\n";
a.printset();
cout<<"\n";
cout<<"the content of list b";
cout<<"\n";
b.printset();
d.unionof();
return 1;
Thu Sep 08, 2011 9:38 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.