35657

Untitled

Feb 16th, 2024
1,118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.     setlocale(LC_ALL, "ru");
  8.  
  9.     const int size = 31;
  10.  
  11.     int arr[size]{ -20, -15, -18, -23, -11, -20, -15, -18, -23, -11, -20, -15, -18, -23, -11, -20, -15, -18, -23, -11, -20, -15, -18, -23, -11, -32};
  12.  
  13.     int sum = 0;
  14.  
  15.     int count = 0;
  16.  
  17.     for (int i = 0; i < size; i++) {
  18.         sum += arr[i];
  19.     }
  20.  
  21.     int temp = sum / size;
  22.  
  23.     for (int i = 0; i < size; i++) {
  24.         if (arr[i] < temp) {
  25.             count++;
  26.         }
  27.     }
  28.  
  29.     cout << "Средняя температура: " << temp << " градусов. Температура опускалась ниже средней " << count << " раз." << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment