【题解】16643. 统计数字

统计数字

https://ac.nowcoder.com/acm/problem/16643

为大家介绍一种使用 map 的解法,代码很简洁。

#include<bits/stdc++.h>

using namespace std;

int main() {
    int n, t;
    map<int, int> m;
    cin >> n;
    for(int i = 0; i < n ; i++) {
        cin >> t;
        m[t]++;
    }
    for(auto it = m.begin() ; it != m.end() ; it++) {
        cout << it->first << ' ' << it->second << endl;
    }
    return 0;
}
全部评论
好像运行的时候显示 "C:\Users\计算机\Desktop\未命名1.cpp [Error] 'it' does not name a type
点赞 回复 分享
发布于 2020-12-03 21:31

相关推荐

2025-12-18 18:23
深圳大学 前端工程师
程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

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