输入孩子的姓名, 用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;
}

你可能感兴趣的:(nbsp)