Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- #include <time.h>
- int main() {
- const int n = 9;
- int a[n];
- srand(time(NULL));
- for (int i = 0; i < n; i++) {
- a[i] = rand() % 19 + 5;
- printf("%d ", a[i]);
- }
- printf("\n\n");
- int max = a[0], k_max = 1, min = a[0], k_min = 1;
- for(int i = 1; i < n; i++) {
- if (a[i] > max) {
- max = a[i];
- k_max = 1;
- } else if (a[i] < min) {
- min = a[i];
- k_min = 1;
- } else if (a[i] == max)
- k_max++;
- else if (a[i] == min)
- k_min++;
- }
- double s = (max * k_max + min * k_min) / (double)(k_max + k_min);
- printf("%lf", s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement