CCF认证 2019-3 小中大
作者:互联网
水题
#include <iostream>
using namespace std;
int n;
int Max, Min, Middle;
double Middle1;
int main() {
scanf("%d",&n);
int arr[n];
for(int i = 0; i < n; ++i) {
scanf("%d",&arr[i]);
}
Max = arr[0];
Min = arr[n-1];
if(Max < Min) {
Max = arr[n-1];
Min = arr[0];
}
if(n % 2 == 0) {
if((arr[n/2-1] + arr[n/2]) % 2 == 0){
Middle = (arr[n/2-1] + arr[n/2]) / 2;
printf("%d %d %d",Max,Middle,Min);
} else {
Middle1 = (arr[n/2-1] + arr[n/2]) / 2.0;
//.1f 用来四舍五入保留小数点后一位
printf("%d %.1f %d",Max,Middle1,Min);
}
}
else {
Middle = arr[n/2];
printf("%d %d %d",Max,Middle,Min);
}
return 0;
}
标签:arr,小中大,Min,int,Max,Middle,Middle1,2019,CCF 来源: https://blog.csdn.net/shadiao_boy/article/details/121388934