map,max_element仿函数的写法
来源:互联网 发布:朵朵淘宝小号批发 编辑:程序博客网 时间:2024/04/28 00:58
一道很典型的题目,本文章仅作备忘使用。
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2521
#include <iostream>#include <map>#include <algorithm>using namespace std;class comp{public:bool operator () (const pair< int, int > &a, const pair < int, int > &b){return a.second == b.second ? a.first > b.first : a.second < b.second; }};int main(){int n;while(cin>>n){map<int, int> a;while(n--){int num;cin>>num;++a[num];}map<int,int>::iterator it_max = max_element(a.begin(),a.end(),comp());cout<<it_max->first<<' '<<it_max->second<<endl;}}
- map,max_element仿函数的写法
- C++ map的使用 (仿函数写法)
- *max_element函数和*min_element函数
- 自定义结构作为map的key,比较函数写法
- 自定义结构作为map的key,比较函数写法
- ibtatis 的写法map
- max_element
- max_element
- max_element
- max_element
- *max_element
- STL中的取反器和绑定器 仿函数的写法--之前写的不是很好
- max_element和min_element的用法
- max_element和min_element的用法
- sort函数、max_element和min_element函数
- C++: *max_element函数和*min_element函数
- 两个很实用很方便的函数核心及用法{(lower_bound)+(max_element))~~
- stl序列容器(map和set)的仿函数排序
- __m128i类型的解析
- 正则表达式规则(六)
- ubuntu12.04没有/var/log/messages解决
- C++教程
- Android PowerManager 详解
- map,max_element仿函数的写法
- Codeforces Round #185 (Div. 1) && (Div. 2)
- Android Animation学习笔记
- zoj1008 gnome tetravex 很久之前的dfs
- A Knight's Journey(简单dfs)
- 关于android分辨率兼容(屏幕适配)问题
- Argo源码阅读(六):ArgoDispatcher
- 修改/etc/fstable自动挂载磁盘设备
- jquery的treeview插件 调用样例(动态数据)