| | |
function for merging two lists
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2006
Posts: 6
Reputation:
Solved Threads: 0
I am working out a function that merges two lists and returns a pointer to a third list which contains the merged lists. Can anyone help? Here is what I have thus far:
C++ Syntax (Toggle Plain Text)
/STLList - use the list container of std library #include <list> #include <string> #include <cstdio> #include <iostream> //declare three list of objects using namespace std; list <string> Anames; list <string> BastroSigns; list <string> MergedNamesSigns; int main() { // input string cout << "input data - name - input 0 to end" << endl; while (true) { string name; cin >> name; if (( name.compare("x") == 0) || (name.compare ("x") == 0)) { break; } Anames.push_back (name); } // sort list Anames.sortedInsert (); //display list A cout << "output is: " << endl; while (!Anames.empty()) { // get first on list string name = Anames.front(); cout << name<< endl; // remove displayed name from list Anames.pop_front(); } / input string cout << "input data - astrological sign - input 0 to end" << endl; while (true) { string sign; cin >> sign; if (( sign.compare("x") == 0) || (sign.compare ("x") == 0)) { break; } sign.push_back (sign); } // sort list BastroSigns.sortedInsert (); //display list B cout << "output is: " << endl; while (!BastroSigns.empty()) { // get first on list string sign = BastroSign.front(); cout << sign<< endl; // remove displayed sign from list BastroSigns.pop_front(); } createsortedList() { } mergelists() //someOperation //someNewlist //somepointer to someNewList system ("PAUSE") ; return 0;
Last edited by WolfPack; Jul 22nd, 2006 at 10:02 am.
Please format your code
http://www.daniweb.com/techtalkforum...cement8-3.html
Colourful, but variable spaced and unindented - bad.
Monochrome, fixed width and indented - good.
http://www.daniweb.com/techtalkforum...cement8-3.html
Colourful, but variable spaced and unindented - bad.
Monochrome, fixed width and indented - good.
Haven't you even tried writing the merge function? You may have written the other parts, but that is not relevent here. Merging two lists can't be that hard. It is just a matter of connecting the tail of one list, with the head of the other list.
Please remember that when you ask a question, you must try to post only the parts that are needed for us to answer that particular question. Posting all code and expecting us to weed through that is outright rude.
Since you are using the standard list, you can use the splice method.
Please remember that when you ask a question, you must try to post only the parts that are needed for us to answer that particular question. Posting all code and expecting us to weed through that is outright rude.
Since you are using the standard list, you can use the splice method.
バルサミコ酢やっぱいらへんで
•
•
Join Date: Jul 2006
Posts: 6
Reputation:
Solved Threads: 0
Hi Wolfpack. thank you for responding. Sorry about the bad manners. I am new to this..I assure you I am a professional and polite person. The problem I am working on is basically to do the merge of two lists without using the std library. I have looked every where and I cannot find the code for the stl merge (). Is there a place I can find such things. I think this is analogous to finding the code behind operators and keywords. What are your thoughts? Can you help - I think I am being asked to re-invent the wheel..Thank you for your help.
No need to appologise. We know you are a good fellow.
If you are already using the standard list, what is keeping you from using the merge function?
Well this code is old, but you can take a look. The copyright says that it is free as long as you do not delete the disclaimer. If anybody sees any legal issues in posting this link here, notify me and I will delete it.
Unless you are writing this code for academic purposes, I'd advice you to use the reliable standard library.
•
•
•
•
The problem I am working on is basically to do the merge of two lists without using the std library.
•
•
•
•
I have looked every where and I cannot find the code for the stl merge (). Is there a place I can find such things.
•
•
•
•
I think this is analogous to finding the code behind operators and keywords. What are your thoughts? Can you help - I think I am being asked to re-invent the wheel.
バルサミコ酢やっぱいらへんで
![]() |
Similar Threads
- help with functions (Python)
- MERGING LISTS need help with this one (C++)
- need help with code (C++)
- stack of linked lists (C++)
Other Threads in the C++ Forum
- Previous Thread: My Emergency Airtime Recharge Service
- Next Thread: How to make windows form from c++ code (GUI)
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






