Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 101;
- int arr[N];
- int main()
- {
- int n;
- scanf("%d", &n);
- for (int i = 1; i <= n; ++i)
- scanf("%d", &arr[i]);
- sort(arr+1, arr+n+1);
- int sum = 0, mxi = 0, mxc = 0, cnt = 0;
- for (int i = 1; i <= n; ++i) {
- if (arr[i] != arr[i-1])
- cnt = 0;
- ++cnt;
- if (cnt >= mxc) {
- mxc = cnt;
- mxi = arr[i];
- }
- sum += arr[i];
- }
- double med = n%2 == 0 ? ((arr[n/2]+arr[n/2+1])/2.0) : arr[n/2+1];
- printf("%.1f\n%.1f\n%.1f", sum*1.0/n, med, mxi*1.0);
- return 0;
- }
Add Comment
Please, Sign In to add comment