touwangyi 2015-11-02 06:47 采纳率: 60%
浏览 1483
已采纳

hdu 1236一直re,跪求解释

一直re,求大神解释 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1236

 #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct student
{
    char kaohao[25];
    int score;
};
bool cmp(student x,student y)
{
    if(x.score!=y.score)return x.score>y.score;
    else return strcmp(x.kaohao,y.kaohao)<=0;
}
int main()
{
    int renshu,tishu,fenxian,ji;
    student a[1005];
    while(scanf("%d",&renshu) && renshu)
    {
        ji = 0;
        memset(a,0,sizeof(a));
        int count,tifen[25];
        scanf("%d%d",&tishu,&fenxian);
        for(int i = 1;i<=tishu;i++)
        {
            scanf("%d",&tifen[i]);
        }
        for(int i = 1;i<=renshu;i++)
        {
            getchar();
            scanf("%s%d",a[i].kaohao,&count);
            for(int j = 1;j<=count;j++)
            {
                int temp;
                scanf("%d",&temp);
                a[i].score += tifen[temp];
            }
            if(a[i].score>=fenxian)
                ji++;
        }
        sort(a+1,a+renshu+1,cmp);
        printf("%d\n",ji);
        for(int i = 1;;i++)
        {
            if(a[i].score<fenxian)
            {break;}
            else printf("%s %d\n",a[i].kaohao,a[i].score);
        }
    }
}
  • 写回答

1条回答 默认 最新

  • BoostZ 2015-11-02 07:53
    关注

    最后输出的时候,如果所有人都过线了,会造成数组越界的情况吧。
    另外吐槽一下,这种中文拼音和英文单词掺杂的写法实在太丧病了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line