#include <map>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
using namespace std;
string data =
"Иванов Роман Михаил\n"
"Петров Алена Ира\n"
"Сидоров Галя\n"
"Рыбин Олег Костя Игорь\n";
int main()
{
map<string, string> mymap;//Наша карта
map<string, string>::iterator it;//Итератор
string fam;//Строка с фамилией
string nam;//Строка с именами детей
stringstream ss;
ss.str(data);
//Цикл чтения
cout<<"input.txt :\n";
while(!ss.eof())
{
if(getline(ss,fam,' '))
if(getline(ss,nam,'\n'))
{
mymap.insert(make_pair(fam,nam));
cout<<fam<<" "<<nam<<endl;
}
}
cout<<"output.txt :\n";
for (it = mymap.begin(); it != mymap.end(); it++)
cout<<(*it).second<<" ";
return 0;
}