1049 '最爱' 浙江中医药大学

来源:互联网 发布:淘宝 评价 看不到 编辑:程序博客网 时间:2024/05/17 03:57

哈哈哈,这道题终于让自己感觉  自己的代码  档次提升了不少!!!


AC代码:

#include<cstdio>
#include<cmath>
#include<algorithm>


using namespace std;


bool compare(int x,int y)
{
    return x > y;
}
int main()
{
    int m;
    while((scanf("%d",&m)) != EOF)
    {
    int t = 1, j = 0, a[m], c[m];
    for(int i = 0; i < m; i++)
        {
            scanf("%d", &a[i]);
        }
    sort(a,a+m,compare);
    for(int i = 0; i < m - 1;)
        {
            while(a[i+1] == a[i])
             {
                 t++;
                 i++;
             }
             c[j] = t;
             t = 1;
             if(a[i+1] != a[i])
             {
                 i++;
             }
             j++;
        }
        if(j > 4)
        {
            printf("%d\n",c[4]);
        }
    }
    return 0;
}


0 0
原创粉丝点击