| | |
C++ list.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 57
Reputation:
Solved Threads: 1
Hi all,
I am playing around with list and I figure out how to merge two lists and all. But I have no idea how can I integrate one list onto another. For example A = {1,2,3,4,10,11} and B = { 5,6,7} Then my integrated list should be
{1,5,2,6,3,7,4,10}. I would have figured out of two lists are of the same length but they aren't. Two lists can be varied in terms of size.
I am writing a free function so here is my approach :
Thank you for any help.
I am playing around with list and I figure out how to merge two lists and all. But I have no idea how can I integrate one list onto another. For example A = {1,2,3,4,10,11} and B = { 5,6,7} Then my integrated list should be
{1,5,2,6,3,7,4,10}. I would have figured out of two lists are of the same length but they aren't. Two lists can be varied in terms of size.
I am writing a free function so here is my approach :
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <list> using namespace std; template <class T> T integrateList(const& list<T> i, const& list<T> m) { list<T>::const_iterator iter; what exactly do I need to do here?I know how I Can merge the two list? But how can I integrate or collate them? }
C++ Syntax (Toggle Plain Text)
int main() { list<int> listA; list<int> listB; list<int> newList; listA.push_back(1); listA.push_back(2); listA.push_back(3); listA.push_back(4); listA.push_back(10); listA.push_back(11) listB.push_back(5); listB.push_back(6); listB.push_back(7); newList = integrateList(listA, listB); cout<<newList <<endl; return 0; }
Thank you for any help.
0
#4 Oct 26th, 2009
Something like this : ?
1) Create a result list
2) Merge list A and list B
3) copy result list to list A, while making sure that list A has enough add at each insertion.
1) Create a result list
2) Merge list A and list B
3) copy result list to list A, while making sure that list A has enough add at each insertion.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
•
•
Join Date: Mar 2008
Posts: 57
Reputation:
Solved Threads: 1
0
#5 Oct 26th, 2009
•
•
•
•
Something like this : ?
1) Create a result list
2) Merge list A and list BC++ Syntax (Toggle Plain Text)
T inteGrateList(const list<T> i, const list<T> m) { list<T>::const_iterator p; list<T> resultingList; i.merge(m) // merge list m in i; now m is empty }
3) copy result list to list A, while making sure that list A has enough add at each insertion.
![]() |
Similar Threads
- Problem with extracting file names from the file names returned by FTP LIST command (C#)
- Update element in list (C++)
- Help with adding to an empty list (Python)
- Simple Linked List with user input (C)
- How to recursively find a value in a linked list (Java)
- A List Script? (PHP)
- Help with list 'subtraction' (Python)
Other Threads in the C++ Forum
- Previous Thread: Extra Paramaters
- Next Thread: I don't know how to make this float function work correctly.
Views: 198 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui iamthwee ifstream input int java lib library lines linkedlist linker loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return sort string strings struct studio system temperature template templates test text text-file tree unix url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






