您的位置:首页 > 其它

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

2014-07-17 16:36 225 查看
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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: