作业介绍

#include <bits/stdc++.h>
using namespace std;
int n;
double a[305];
double sum,ave,maxx=-9999999,minn=999999999;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
		if(a[i]>maxx)maxx = a[i];
		if(a[i]<minn)minn = a[i];
	}
	ave = (sum-maxx-minn)/(n-2);
	double ans = 0;
	int Max=0,Min=0;
	for(int i=1;i<=n;i++){
		if(a[i]==maxx && Max==0){
			Max = 1;
			continue;
		}
		if(a[i]==minn && Min==0){
			Min = 1;
			continue;
		}
		ans = max(ans,abs(a[i]-ave));
	}
	printf("%.2lf %.2lf\n",ave,ans);
	return 0; 
}
#include <bits/stdc++.h>
using namespace std;
int n,a[1005],book[105];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		book[a[i]]++;
	}
	int maxx = 0;
	for(int i=0;i<=100;i++){
		if(book[i]>maxx){
			maxx = book[i];
		}
	}
	for(int i=1;i<=n;i++){
		if(book[a[i]]==maxx){
			cout<<a[i]<<' '<<maxx<<endl;
			break;
		}
	}
	return 0;
}
状态
已结束
题目
18
开始时间
2023-4-15 12:00
截止时间
2023-7-31 11:59
可延期
0 小时