int main() { int ta[] = {3,8,0,4,1,6}; int n = 6; int i = 0, j = 0; int t = 0; double average = 0; for (i; i < n; i++) { for (j=0; j < n-i-1; j++) { if (ta[j] > ta[j+1]) { t = ta[j]; ta[j] = ta[j + 1]; ta[j + 1] = t; } } } for (i = 1; i < n; i++) { if (i != n - 1)average += ta[i]; } average /= n-2; printf("max:%d\nmin:%d\naverage:%lf", ta[n - 1], ta[0], average); } 简单的冒泡排序