[ create a new paste ] login | about

Link: http://codepad.org/KNe3UsXV    [ raw code | output | fork ]

C++, pasted on Aug 26:
#include <iostream>
#include <list>

using namespace std;

int main()
{
  list<char> lst1, lst2;
  int i;

  for (i = 0; i < 10; i += 2)
    lst1.push_back('A' + i);
  for (i = 1; i < 11; i += 2)
    lst2.push_back('A' + i);
  cout << "lst1: ";
  list<char>::iterator p = lst1.begin();
  while (p != lst1.end()) {
    cout << *p;
    p++;
  }
  cout << endl << endl;
  cout << "lst2: ";
  p = lst2.begin();
  while (p != lst2.end()) {
    cout << *p;
    p++;
  }
  cout << endl << endl;
  lst1.merge(lst2);
  cout << "lst1 + lst2: ";
  p = lst1.begin();
  while (p != lst1.end()) {
    cout << *p;
    p++;
  }
  return 0;
}
/* end */


Output:
1
2
3
4
5
lst1: ACEGI

lst2: BDFHJ

lst1 + lst2: ABCDEFGHIJ


Create a new paste based on this one


Comments: