Switch to full style
For C/C++ coders discussions and solutions
Post a reply

can u check tis code to perform union & intersection of list

Tue Sep 06, 2011 10:55 am

Code:
#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




Re: can u check tis code to perform union & intersection of list

Thu Sep 08, 2011 9:38 pm

what is your problem with this snippet ?

Post a reply
  Related Posts  to : can u check tis code to perform union & intersection of list
 code for check availability     -  
 Linked List C++ Code Implementation     -  
 list insertion sorting code in c++     -  
 Read list of files in java I/O code     -  
 Computes the intersection of arrays     -  
 Get union of two arrays set and print it     -  
 Perform Division by Shifting to the Right     -  
 Perform Multiplication by Shift Left Operations     -  
 check if number is odd or even     -  
 Check DNS error     -  

Topic Tags

C++ Math