题解 | #合并表记录#

合并表记录

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;

}

全部评论

相关推荐

06-23 11:43
门头沟学院 Java
allin校招的烤冷...:我靠,今天中午我也是这个hr隔一个星期发消息给我。问的问题还是一模一样的😅
点赞 评论 收藏
分享
06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-23 14:18
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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