Degree

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.(≤ 10000).Next line contains positive integer .Each integer is less than 10000.

Output

For each test case, print an answer .

Sample Input

1
5
5 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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值