1077 互评成绩计算

double round(double r)
{
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
#define MMAX 105
int main()
{
    //freopen("D:\\文件夹\\Desktop\\use.txt","r",stdin);
    int N,M;scanf("%d %d\n",&N,&M);
    int score[MMAX];
    for(int i = 0;i < N;++i){
        memset(score,0,MMAX);
        int max = -1,min = 100;
        int scor = 0;
        int hefa = 1; //合法数据的个数 
        scanf("%d",&score[0]);
        for(int j = 0;j < N-1;++j){
            int t;scanf("%d",&t);
            if(t >=0 &&t <=M) score[hefa++] = t;
            else continue;
            if(t>max) max = t;
            if(t < min) min = t;
            scor += t;
        }
        printf("%d",(int)round(((double)(scor - max - min)/(double)(hefa-3) + (double)score[0])/2));
        if(i != N-1) printf("\n");
    }
    return 0;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。