输入孩子的姓名, 用map存储,&…

int main (int argc, char* argv[])
{
    std::ios::sync_with_stdio (false);
    string firstName, lastName;
    multimap< string, vector< string>>kidsNames;
    while (cin >> firstName >> lastName) {
        vectorlastNames;
        lastNames.push_back (lastName);
        kidsNames.insert({ firstName, lastNames});
    }
    cout << "There are the names:" << endl;
    for (auto map_it = kidsNames.cbegin (); map_it != kidsNames.cend (); ++map_it)
        for (auto vec_it = map_it->second.cbegin (); vec_it != map_it->second.cend (); ++vec_it)
            cout << map_it->first << *vec_it << endl;
    return 0;
}
posted @ 2014-07-18 21:07  wu_overflow  阅读(195)  评论(0编辑  收藏  举报