[HdOJ]1800 Flying to the Mars

来源:互联网 发布:java list<> 编辑:程序博客网 时间:2024/04/27 17:56
#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;}

找出相同的数字最多有多少个

0 0
原创粉丝点击