Total members 11893 |It is currently Tue Nov 05, 2024 7:43 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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





Author:

what is your problem with this snippet ?

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  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     -  
 Get union of two arrays set and print it     -  
 Computes the intersection of arrays     -  
 Perform Division by Shifting to the Right     -  
 Perform Multiplication by Shift Left Operations     -  
 Check DNS error     -  
 check if domain name is taken by php     -  



Topic Tags

C++ Math






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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