Advertisement
Infiniti_Inter

Olya(14)

Dec 25th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <queue>
  6. using namespace std;
  7.  
  8. ifstream in("input.txt");
  9. ofstream out("output.txt");
  10.  
  11.  
  12. int main()
  13. {
  14.     int n;
  15.     in >> n;
  16.     queue<int> q;
  17.     int sum = 0;
  18.     int cnt = 0;
  19.     for (int i = 0; i < n; ++i)
  20.     {
  21.         int cur; in >> cur;
  22.         q.push(cur);
  23.         if (cur % 2 == 0)
  24.         {
  25.             sum += cur;
  26.             cnt++;
  27.         }
  28.     }
  29.     double avg = 1.*sum / cnt;//1.*sum - приведение к типу double
  30.     queue<int> temp;
  31.     while (!q.empty())
  32.     {
  33.         int cur = q.front(); q.pop();
  34.         if (cur > avg)
  35.             out << cur << " ";
  36.         else
  37.             temp.push(cur);
  38.     }
  39.     while (!temp.empty())
  40.     {
  41.         int cur = temp.front(); temp.pop();
  42.         out << cur << " ";
  43.     }
  44.     /*
  45.         пример
  46.         5
  47.         1 2 3 4 5
  48.     */
  49.  
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement