【题解】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

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
代码飞升_不回私信人...:啊喂笨蛋算法为什么写查找,线程池怎么放计网上去了,写动态规划真的不会被狠狠地制裁吗oi
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

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