#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

// egyet balról, egyet jobbról:
struct zipp
{
    zipp() : flag(true) { }
    bool operator()(const string& s1, const string& s2)
    {
        flag = !flag;
        return flag;
    }
    bool flag;
};

int main()
{
    ifstream if1("file1.txt");
    ifstream if2("file2.txt");

    merge( istream_iterator<string>(if1), istream_iterator<string>(),
           istream_iterator<string>(if2), istream_iterator<string>(),
           ostream_iterator<string>(cout,"\n"), zipp() );
    return 0;
}