1077 互评成绩计算 (20 分)
【我的代码】
//1077 互评成绩计算 (20 分)
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
int N, M;
scanf("%d %d", &N, &M);
double G1, temp1, G2;
double G[N];
int count = 0;//有效成绩
for(int i = 0; i < N; i++){
int x = 0;
for(int i = 0; i < N; i++){
cin>>temp1;
//判断合法非法
if(temp1 >= 0 && temp1 <= M){
G[x++] = temp1;
}
}
G2 = G[0];//老师评分
sort(G+1 ,G+x);
temp1 = 0;
for(int i = 2; i < x-1; i++){
temp1 += G[i];
count = i - 1;
}
cout<<round(((temp1 / count) + G2) / 2)<<endl;
}
return 0;
}
【思路】
很常规的题目,注意记住关于四舍五入,C++有封装好的库函数可以直接调用。
继续阅读与本文标签相同的文章
上一篇 :
1076 Wifi密码 (15 分)
下一篇 :
详解 leetcode 221 题:最大正方形
-
Angular 组件样式
2026-05-21栏目: 教程
-
1074 宇宙无敌加法器 (20 分)
2026-05-21栏目: 教程
-
1073 多选题常见计分法 (20 分)
2026-05-21栏目: 教程
-
1075 链表元素分类 (25 分)
2026-05-21栏目: 教程
-
详解 leetcode 221 题:最大正方形
2026-05-21栏目: 教程
