题解 | #合并表记录#

合并表记录

https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201

#include <iostream>
#include <map>
using namespace std;

int main() {
    int num;
    int a,b;
    cin>>num;
map<int,int> mp;
while(cin>>a>>b)
{
    mp[a]+=b;

}
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
    {
        cout<<it->first<<" "<<it->second<<endl;

    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

投递中移(苏州)软件技术有限公司等公司6个岗位 > 牛客解忧铺
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务