Question subject: can u check tis code to perform union & intersection of list
Posted: 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;
msi_333
Question subject: Re: can u check tis code to perform union & intersection of list
Posted: Thu Sep 08, 2011 9:38 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2272 Location: Earth Has thanked: 39 time Have thanks: 61 time
what is your problem with this snippet ?
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )