首页
学习
活动
专区
圈层
工具
发布
29 篇文章
1
PAT (Basic Level) Practice (中文)1047 编程团体赛
2
PAT (Basic Level) Practice (中文)1083 是否存在相等的差
3
PAT (Basic Level) Practice (中文)1082 射击比赛
4
PAT (Basic Level) Practice (中文)1081 检查密码
5
PAT (Basic Level) Practice (中文)1077 互评成绩计算
6
PAT (Basic Level) Practice (中文)1076 Wifi密码
7
PAT (Basic Level) Practice (中文)1064 朋友数
8
PAT (Basic Level) Practice (中文)1063 计算谱半径
9
PAT (Basic Level) Practice (中文)1057 数零壹
10
PAT (Basic Level) Practice (中文)1056 组合数的和
11
PAT (Basic Level) Practice (中文)1042 字符统计
12
PAT (Basic Level) Practice (中文)1041 考试座位号
13
PAT (Basic Level) Practice (中文)1023 组个最小数
14
PAT (Basic Level) Practice (中文)1022 D进制的A+B
15
PAT (Basic Level) Practice (中文)1019 数字黑洞
16
PAT (Basic Level) Practice (中文)1007 素数对猜想
17
PAT (Basic Level) Practice (中文)1091 N-自守数
18
PAT (Basic Level) Practice (中文)1026 程序运行时间
19
PAT (Basic Level) Practice (中文)1061 判断题
20
PAT (Basic Level) Practice (中文)1086 就不告诉你
21
PAT (Basic Level) Practice (中文)1016 部分A+B
22
PAT (Basic Level) Practice (中文)1012 数字分类
23
PAT (Basic Level) Practice (中文)1013 数素数
24
PAT (Basic Level) Practice (中文)1011 A+B 和 C
25
PAT (Basic Level) Practice (中文)1009 说反话
26
PAT (Basic Level) Practice (中文)1008 数组元素循环右移问题
27
PAT (Basic Level) Practice (中文)1006 换个格式输出整数
28
PAT (Basic Level) Practice (中文)1004 成绩排名
29
PAT (Basic Level) Practice (中文)1002 写出这个数

PAT (Basic Level) Practice (中文)1077 互评成绩计算

1077 互评成绩计算

在浙大的计算机专业课中,经常有互评分组报告这个环节。一个组上台介绍自己的工作,其他组在台下为其表现评分。最后这个组的互评成绩是这样计算的:所有其他组的评分中,去掉一个最高分和一个最低分,剩下的分数取平均分记为 G1;老师给这个组的评分记为 G2。该组得分为 (G1+G2)/2,最后结果四舍五入后保留整数分。本题就要求你写个程序帮助老师计算每个组的互评成绩。

输入格式:

输入第一行给出两个正整数 N(> 3)和 M,分别是分组数和满分,均不超过 100。随后 N 行,每行给出该组得到的 N 个分数(均保证为整型范围内的整数),其中第 1 个是老师给出的评分,后面 N−1 个是其他组给的评分。合法的输入应该是 [0,M] 区间内的整数,若不在合法区间内,则该分数须被忽略。题目保证老师的评分都是合法的,并且每个组至少会有 3 个来自同学的合法评分。

输出格式:

为每个组输出其最终得分。每个得分占一行。

输入样例:

6 50 42 49 49 35 38 41 36 51 50 28 -1 30 40 36 41 33 47 49 30 250 -25 27 45 31 48 0 0 50 50 1234 43 41 36 29 42 29

输出样例:

42 33 41 31 37 39

分析:

注:结果不能是 double 类型,应为 int 类型

代码:

代码语言:javascript
复制
#include<stdio.h>
int temp[10000];
int temparr[10000];
int ll=0;
int fun(int G2,int sum,int t)
{
    int i;
    int index1=0;
    int index2=0;
    for(i=1;i<t;i++)
    {
        if(temp[i]>=temp[index1]) index1=i;
    }
    for(i=1;i<t;i++)
    {
        if(temp[i]<=temp[index2]) index2=i;
    }
   double G1=(sum-temp[index1]-temp[index2])/(double)(t-2);
   double result=(G1+(double)G2)/2.0;
   double tt=result-(int)result;
   if(tt>=0.5) return (int)result+1;
   else return (int)result;


}
int arr[1000][1000];
int main()
{
    int N;
    int M;
    int i,j;
    int t;
    int sum;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++)
    {
        t=0;
        sum=0;
        for(j=0;j<N;j++)
        {
            scanf("%d",&arr[i][j]);
            if(j!=0)
            {
                if(arr[i][j]>=0&&arr[i][j]<=M) {temp[t++]=arr[i][j];sum+=arr[i][j];}

            }
        }
        double result=fun(arr[i][0],sum,t);
        temparr[ll++]=result;
       // printf("%.0lf\n",result);
    }
    for(i=0;i<ll;i++)
        printf("%d\n",temparr[i]);
    return 0;

}
下一篇
举报
领券