#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
while (cin>>N)
{
map<int,pair<string,int>>mp;
string s;
int a,b,M;
for(int i = 0;i<N;i++)
{
cin>>s>>a>>b;
mp[a] = make_pair(s,b);
}
cin>>M;
for(int i = 0;i<M;i++)
{
cin>>a;
cout<<mp[a].first<<" "<<mp[a].second<<endl;
}
}
return 0;
}
/*
*
4
3310120150912233 2 4
3310120150912119 4 1
3310120150912126 1 3
3310120150912002 3 2
2
3 4
*/
C++ Map数据结构应用实例
本文通过一个C++程序示例,展示了如何使用STL中的Map数据结构进行数据存储和检索。具体包括:从标准输入读取数据,将数据存储在Map中,并根据输入的键输出相应的值。此示例适用于理解Map的基本操作和使用场景。
378

被折叠的 条评论
为什么被折叠?



