题解 | #合并表记录#

合并表记录

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

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

int main() {
    //使用有序关联容器,其中的值不能重复, map来实现
    map<int, int>  word_count;
    int N = 0;
    cin >> N;
    for (int i = 0; i<N; i++)
    {
        int a,b;
        cin>>a>>b;
        word_count[a] +=b;
    }
    for(auto w: word_count)
    {
        cout<<w.first <<' '<< w.second << endl;
    }
    return 0;

    }

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

全部评论

相关推荐

八股刚起步,看了javaguide,小林coding,还有面渣,感觉面渣是体验最好的,请问只看面渣够用吗,有不完善的需要补吗?
码农索隆:先背最基础的知识,然后理解情景题,现在面试大多数喜欢问情景题,更考验面试者的基础和临场发挥情况
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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