无量塔姬子 @ 2021-10-29 23:41:48
#include<stdio.h>
int main()
{
float number;
int number_ping;
int score[1001];
int i, j;
int all_score = 0;
scanf_s("%d", &number_ping);
for (i = 1; i <= number_ping; i++){
scanf_s("%d", &score[i]);
}
score[0] = number_ping - 2;
for (i = 0; i <= 10; i++){
for (j = 1; j <= number_ping; j++){
if (score[j] == i){
score[j] = 0;
break;
}
}
if (score[j] == 0){
break;
}
}
for (i = 10; i >= 0; i--) {
for (j = 1; j <= number_ping; j++) {
if (score[j] == i) {
score[j] = 0;
break;
}
}
if (score[j] == 0)
{
break;
}
}
for (j = 1; j <= number_ping; j++) {
all_score += score[j];
}
number = (all_score * 1.0) / score[0];
printf("%.2f", number);
}
我不知道为什么,我这个代码自己测试的时候第一个测试点是对的。但是放上去就不行了,我不知道自己哪里有问题,请大佬们赐教。
by 褚橙 @ 2021-10-30 00:15:50
@无量塔姬子 你的代码写的太复杂了,而且您自己的样例,跟第一个测试的不一样
by 褚橙 @ 2021-10-30 00:28:51
@无量塔姬子 您这个第三个for循环中score[i]在上文中已经跟新过了
by 褚橙 @ 2021-10-30 00:30:52
@无量塔姬子 可能score[number_ping]为零,且score中没有10,则score[number_ping]=0,也会break
by 褚橙 @ 2021-10-30 00:32:29
#include<bits/stdc++.h>
using namespace std;
int n;
double a,ans,maxv,minv=0x3f3f3f3f;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a;
ans+=a;
maxv=max(maxv,a);
minv=min(minv,a);
}
printf("%.2f",(ans-maxv-minv)/(n-2));
return 0;
}
这是本蒟蒻的代码,写的太烂了,我太菜了
by 无量塔姬子 @ 2021-10-30 12:08:44
@褚橙 谢谢大佬