题解 | #合并表记录#现学的map

合并表记录

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

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

int main(){
    map<int,int> m;
    int n,x,y;
    cin>>n;
    for(int i = 0;i < n;i++){
        cin>>x>>y;
        m[x] += y;
    }
    for(auto i : m){
        cout<<i.first<<" "<<i.second<<endl;
    }
}
全部评论

相关推荐

07-20 21:57
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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