您的位置:首页 > 其它

[HdOJ]1800 Flying to the Mars

2015-02-10 10:34 260 查看
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
long int a[3010];
int n,i,count,max;
while(scanf("%d",&n)!=EOF)
{
max=1;
for(i=0;i<n;i++)
{
scanf("%ld",&a[i]);
}
sort(a,a+n);
count=1;
for(i=0;i<n-1;i++)    // 只进行一次循环就可以找出相同数字的个数了    小心越界
{
if(a[i]<a[i+1])
{
count=1;
}
else
{
count++;
}
max=max>count?max:count;
}
printf("%d\n",max);
}
return 0;
}


找出相同的数字最多有多少个
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hash