题解 | #合并表记录#

合并表记录

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

map也太适合这个题了!

#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int, int> hash;
    int num,key,value;   
    cin>>num;
    for(int i=0;i<num;i++)
    {
        cin>>key;
        cin.get();
        cin>>value;
        hash[key]+=value;
    }
    
    for(auto x:hash)
    {
        cout<<x.first<<" "<<x.second<<endl;
    }
}
全部评论

相关推荐

牛至超人:哈工大已经很棒了,不需要加括号了,然后咋没有实习经历呢?火速趁寒假整一段实习,导师不让就狠狠肘击
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务