Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int n, i, maxi = (int)-1e9, mini = (int)1e9;
- double max, min, total, average, a[1000], juedui[1000], juedui_max = (int)-1e9;
- int main()
- {
- scanf("%d", &n);
- for (i = 0; i < n; i++)
- scanf("%lf", &a[i]);
- max = (int)-1e9;
- min = (int)1e9;
- for (i = 0; i < n; i++)
- {
- if (a[i] > max)
- max = a[i], maxi = i;
- if (a[i] < min)
- min = a[i], mini = i;
- total += a[i];
- }
- average = (total - max - min) / (n - 2);
- juedui_max = juedui[0];
- for (i = 0; i < n; i++)
- {
- if (i != mini && i != maxi)
- {
- juedui[i] = a[i] - average;
- if (juedui[i] > 0)
- juedui[i] = juedui[i];
- if (juedui[i] < 0)
- juedui[i] = -juedui[i];
- }
- }
- for (i = 0; i < n; i++)
- if (juedui[i] > juedui_max && i != mini && i != maxi)
- juedui_max = juedui[i];
- printf("%.2lf %.2lf", average, juedui_max);
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment