题解 | #公务员面试#
公务员面试
http://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include<stdio.h> int main() { int n = 0; double arr[7] = { 0.0 }; for (int i = 0; i < 7; i++)//获取7个数字 { scanf("%d", &n); arr[i] = n; } for (int i = 0; i < 6; i++)//排序 { for (int j = 0; j < 6 - i; j++) { if (arr[i] > arr[i + j + 1]) { int tmp = arr[i + j + 1]; arr[i + j + 1] = arr[i]; arr[i] = tmp; } } } printf("%.2lf\n", (arr[1] + arr[2] + arr[3] + arr[4] + arr[5]) / 5);//取中间5个数平均 return 0; }