Not Yet Answered # help me

Discussion Starter Nidaa87 WaltP 2,905 Ancient Dragon 5,243 Discussion Starter Nidaa87 Salem 5,138 Discussion Starter Nidaa87 Discussion Starter Nidaa87 Lerner 582 Discussion Starter Nidaa87 Salem 5,138 Salem 5,138 Ancient Dragon 5,243 Discussion Starter Nidaa87 Discussion Starter Nidaa87 Salem 5,138 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

Please help as soon as possible because with me just one day to hand over the post

0

Read the Rules as you've been asked, and the post titled **Read Me:** Read This Before Posting.

0

It might help to explain your problem is you show something that illustrates what you want to do, because I have no clue what you want.

0

I want the code process

Union

And the intersection between the two linked list

0

So what you really want to start with is something simple like "isMemberOf".

A union is merely a membership test to see if the item is in either list.

An intersection is a membership test to see if the item is in both lists.

How much of the list functionality do you have already, say

- create a list

- insert into a list

- remove from a list.

These are all basic functions which you'll need. If you can't do that much, then we need to help you with those rather than going straight for the complete solution.

0

I wrote this code to add and print linked list

And I have stayed code gymnasts European currencies and the intersection only House 2 linked list

List1, list2

For example:

List 1 = (1,3,5,7,8)

List2 = (1,9,1,3,5,2)

List1 union list2 = (1,3,5,7,8,9,2)

List1 intersection list2 =) 1,3,5)

0

```
#include <iostream>
#include <string>
using namespace std;
struct node
{
int data;
struct node *next;
};
class linkedList
{
node *head;
public:
void create();
void display();
void selectionSort();
void add();
void unita();
void intre();
};
void linkedList :: create()
{
node *newl=NULL,*end=newl;
int data;
head=NULL;
cout<<"\nCreate the List. Press <ENTER> after each entry\n";
for(int i=0;i<=5;i++)
{
cout<<"Enter a number: ";
cin>>data;
newl = new node;
newl->data=data;
if(head==NULL)
head=newl;
else
end->next=newl;
end=newl;
end->next=NULL;
}
cout<<"\nList is Created\n";
}
void linkedList :: display()
{
node *start;
start=head;
while(start!=NULL){
cout<<start->data;
if(start->next!=NULL)
cout<<", ";
start=start->next;
}
}
void linkedList :: selectionSort()
{
node *i, *j;
int temp;
for(i=head;i!=NULL;i=i->next){
for(j=i->next;j!=NULL;j=j->next){
if(i->data > j->data){
temp = i->data;
i->data = j->data;
j->data = temp;
}
}
}
cout<<"\nThe numbers are Sorted\n";
}
void linkedList::add()
{
node *i, *j;
int data;
cout<<"Enter a number: ";
cin>>data;
j = new node;
j->data=data;
int temp;
for(i=head;i!=NULL;i=i->next){
if(i->data > j->data){
temp = i->data;
i->data = j->data;
j->data = temp;
}
}
}
void main()
{
linkedList list1;
list1.create();
cout<<"List1 before sorting "<<endl;
list1.display();
list1.selectionSort();
cout<<"List1 after sorting "<<endl;
list1.display();
linkedList list2;
list2.create();
cout<<"\n\n\n List2 before sorting "<<endl;
list2.display();
list2.selectionSort();
cout<<"List2 after sorting "<<endl;
list2.display();
cout<<"\n\n\nadd\n";
list1.add();
list1.display();
}
```

0

Your formatting leaves a lot to be desired.

```
void linkedList :: create()
{
node *newl = NULL;
node *end = newl;
int data;
head = NULL;
cout << "\nCreate the List. Press <ENTER> after each entry\n";
for(int i = 0; i <= 5; i++)
{
cout << "Enter a number: ";
cin >> data;
newl = new node;
newl->data = data;
if(head == NULL)
head = newl;
else
end->next = newl;
end = newl;
end->next = NULL;
}
cout << "\nList is Created\n";
}
```

Note consistent indenting, spaces before and after operators, etc. It's not only easier to read code that's consistently and appropriately formatted, it's easier to debug too.

Assuming the posted code works as desired then the next step I would do is to decide exactly what constitutes a union. By that I mean do you have only one copy of a given value of data in the union or can you have multiple copies of data in the union? If you can have multiple copies, then just copy one list into the other to get the union. If you want unique copies of data in the union but there are multiple copies of data in either list then you need to get a little more creative.

Likewise, to me intersection means a list that has unique pieces of data that are in both lists from which the intersection is derived. Therefore pick one list as the target and one list as the source. Then you could use a nested loop something like for each node in the source check each node in the target. If a match is found look at each node the intersection. If matched node of the two lists isn't in the intersection then add it to the intersection.

0

I did not understand what it mean MY English is not good

I want the code works the intersection of Union and two list type integer

0

Like I said, a function called "isMemberOf" would be a really useful primitive for working out intersection and union

```
// return true if val is in the list
bool linkedList::isMemberOf( int val );
```

0

In pseudo-code

Intersection

for e = each element in l1

if isElementOf(l2,e) then add e to the result

Union

copy l1 to the result

for e = each element in l2

if NOT isElementOf(result,e) then add e to the result

0

I think the job of that function is to create a third linked list that is the union of l1 and l2

```
Void uinio(linkedlist l1,linkedlist l2)
{
struct node* l3 = 0;
struct node* node = l1;
// add the unique node in l1 to the new linked list
while( node )
{
if( !IsMemberOf(l3, node->data) )
{
// add node->data to l3 list
}
node = node->next;
}
// do the same thing with l2
node = l2;
while( node )
{
if( !IsMemberOf(l3, node->data) )
{
// add node->data to l3 list
}
node = node->next;
}
}
```

0

I thank you very Abietin but this sentence error

bool linkedList::isMemberOf( int val);

0

Why Ietunai error on this sentence bool linkedList:: isMemberOf (int val);

0

Yes, we got that much of the problem already.

The question is, did you just put `bool isMemberOf (int val);`

into the class declaration, without bothering to implement it, or have you tried to implement it and gotten some error messages.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...