0

Hi I am a learning programmer and I am always looking for help along the way. Right now I am struggling with merging two lists into a third list. Here is what I have so far as you can see is three lists I need help with the merge method - any thoughts?

//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();
}
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())
{

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by CyberLev
0

sorry - i was excited to join and in my exhuberance went right into discussing c++.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.