Undertakers @ 2024-10-17 20:30:25
#include <stdio.h>
int main() {
int i,n,min,max,sum;
scanf("%d",&n);
int score[n];
for(i = 0; i < n; i++) {
scanf("%d",&score[i]);
}
for(i = 0; i < n; i++) {
sum+=score[i];
}
minmax(score,n,&min,&max);
sum-=(min+max);
double average=1.0*sum/(n-2);
printf("%.2f",average);
return 0;
}
int minmax(int score[],int len,int*min,int*max)
{
int t;
*max=*min=score[0];
for(t=0; t<len; t++)
{
if(score[t]>*max) *max=score[t];
if(score[t]<*min) *min=score[t];
}
return minmax;
}
by fangkai123 @ 2024-10-17 20:32:22
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int max=-1,min=11;
int sum = 0;
for(int i=0;i<n;i++){
int x;
cin>>x;
sum+=x;
if(x>max){
max = x;
}
if(x<min){
min = x;
}
}
double average = sum-min-max;
printf("%.2lf",average/(n-2));
return 0;
}
by fangkai123 @ 2024-10-17 20:32:38
@Undertakers
by Tiffake @ 2024-10-17 20:33:45
@Undertakers 事实上,在我的编辑器上也过不了编
by hjb13357896690 @ 2024-10-17 20:37:59
@Undertakers 12 29 C:\Users\Administrator\Desktop\2.cpp [Error] 'minmax' was not declared in this scope
过不了,第十二行
by _joker_r @ 2024-10-17 20:46:39
@Undertakers 不对,你前面都没定义minmax函数
by _joker_r @ 2024-10-17 20:47:45
@Undertakers
#include <stdio.h>
int minmax(int score[],int len,int*min,int*max)//挪到前面来
{
int t;
*max=*min=score[0];
for(t=0; t<len; t++)
{
if(score[t]>*max) *max=score[t];
if(score[t]<*min) *min=score[t];
}
return minmax;
}
int main() {
int i,n,min,max,sum;
scanf("%d",&n);
int score[n];
for(i = 0; i < n; i++) {
scanf("%d",&score[i]);
}
for(i = 0; i < n; i++) {
sum+=score[i];
}
minmax(score,n,&min,&max);
sum-=(min+max);
double average=1.0*sum/(n-2);
printf("%.2f",average);
return 0;
}
by Undertakers @ 2024-10-18 10:14:14
@_joker_r 这个还是过不了
by _joker_r @ 2024-10-18 10:16:25
@Undertakers 把minmax改成void类型,去掉return
by _joker_r @ 2024-10-18 10:17:06
#include <stdio.h>
void minmax(int score[],int len,int*min,int*max)//挪到前面来
{
int t;
*max=*min=score[0];
for(t=0; t<len; t++)
{
if(score[t]>*max) *max=score[t];
if(score[t]<*min) *min=score[t];
}
//return minmax;去掉
}
int main() {
int i,n,min,max,sum;
scanf("%d",&n);
int score[n];
for(i = 0; i < n; i++) {
scanf("%d",&score[i]);
}
for(i = 0; i < n; i++) {
sum+=score[i];
}
minmax(score,n,&min,&max);
sum-=(min+max);
double average=1.0*sum/(n-2);
printf("%.2f",average);
return 0;
}
by Undertakers @ 2024-10-18 16:11:47
@_joker_r 过了,谢谢