Advertisement
Spocoman

01. Below Average Only

Nov 22nd, 2023
887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int arrLen, sumNumbers = 0, averageNum, oddSum = 0, evenSum = 0;
  8.     cin >> arrLen;
  9.  
  10.     int* numbers = new int[arrLen];
  11.  
  12.     for (int i = 0; i < arrLen; i++) {
  13.         cin >> numbers[i];
  14.         sumNumbers += numbers[i];
  15.     }
  16.  
  17.     averageNum = (double)sumNumbers / arrLen;
  18.  
  19.     for (int i = 0; i < arrLen; i++) {
  20.         if (numbers[i] <= averageNum) {
  21.             (i % 2 == 1 ? oddSum : evenSum) += numbers[i];
  22.         }
  23.     }
  24.  
  25.     cout << oddSum * evenSum << endl;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement