#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void print_arr(int arr[],int num)
{
for (int j = 0; j < num; j++)
{
printf("%d ", arr[j]);
}
printf("\n");
}
int cmp_int(const void* e1, const void* e2)
{
return *(int*)e1 - *(int*)e2;
}
int main()
{
char str[200] = { 0 };
int arr[50] = { 0 };
float num = 0;
int sum = 0;
gets(str);
int i, j = 0, k = 0;
for (i = 0; str[i] != '-'; i++)
{
if (str[i] >= '0' && str[i] <= '9')
{
arr[j] = arr[j] * 10 + (str[i] - '0');
}
else if (str[i] == ' ' && k < 50)
{
j++;
k++;
}
}
qsort(arr, 50, sizeof(int), cmp_int);
int u = 0;
for (int j = 0; j < 50; j++)
{
if (arr[j] != 0)
{
if (u > 1 && j < 48)
{
sum += arr[j];
num++;
}
u++;
}
}
float average = (float)sum / num;
printf("%.2f\n", average);
return 0;
}
完