Degree
来源:互联网 发布:mac pdf怎么删除文字 编辑:程序博客网 时间:2024/04/30 00:31
CXB would like to find out the maximum repeat frequency in a figure sequence. For instance, the figure sequence as follows: 5,6,7,5,1. According to this sequence, we can draw a conclusion that 5 is the number which is repeated 2 and 2 is answer.
Input
The first line of the input contains ca (ca ≤ 50), For each test cases, there is a number of n.(n ≤ 10000).Next line contains n positive integer .Each integer is less than 10000.
Output
For each test case, print an answer .
Sample Input
155 6 7 5 1
Sample Output
2
题意概述:给定一串数字,找到其中出现次数最多的数字,输出其出现的次数。
解题思路:使用C++标准库中的map做关联式数组使用,就可以轻易的解决这个问题。主要是由于这个问题本身比较简单。
源代码:
#include<iostream>#include<map>using namespace std;int main(){ int T,N,temp,R; map<int,int>coll; map<int,int>::iterator pos; cin>>T; while(T--) { R=0; cin>>N; for(int i=0;i<N;++i) { cin>>temp; ++coll[temp]; } for(pos=coll.begin();pos!=coll.end();++pos) if(R<pos->second)R=pos->second; //获得最大的出现次数 cout<<R<<endl; coll.clear(); //尤其重要,要及时清空,否则会影响下一次的结果 } return 0;}
- Degree
- About doctor degree
- my second degree
- ADVERBS OF DEGREE
- diameter - degree problem
- The cycles per degree
- Pursue a Post-graduate Degree
- CF 7D: Palindrome Degree
- new live for master degree
- CodeForces - 7D Palindrome Degree
- CodeForces 7D Palindrome Degree
- 双向BFS和six degree
- codeforces 7D Palindrome Degree
- Codeforce 7D Palindrome Degree
- 【URAL 1056】Amount of Degree
- 自由度(degree of freedom)
- 697. Degree of an Array
- 697. Degree of an Array
- 关于小米的代码门
- 使用 libevent 和 libev 提高网络应用性能
- 浅析Linux系统启动过程剖析
- Struts集成的校验方式
- Joomla!建设网站-安装
- Degree
- 块设备驱动 linux3.11.4
- Select和epoll的区别 + Linux平台下API解析
- 将一个正整数分解为多个连续整数之和
- C语言实现SOLID原则的模式
- Ringo.js嵌入集成(三):利用RingoJs仿制wordpress的plugin机制
- Cocos2d-x 3.0开发(五)关联程序逻辑与cocoStudio导出文件
- 文献阅读方法
- android之Adapter