题解 | #合并表记录#

合并表记录

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

#include #include #include using namespace std; int main() { int key, value; map<int, int> res; int i; cin >> i; while (i--) { cin >> key >> value; res[key] += value; } for (auto c = res.begin(); c != res.end(); c++) {

    if (c->second != 0) {
        cout << c->first << ' ' << c->second << endl;
    }
}
return 0;

}

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 11:30
点赞 评论 收藏
分享
06-25 09:33
厦门大学 Java
程序员饺子:现在日常估计没啥hc了,等到八月多估计就慢慢有了。双九✌🏻不用焦虑的
投递快手等公司7个岗位
点赞 评论 收藏
分享
码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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