Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <fstream>
- #include <queue>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- int n;
- in >> n;
- queue<int> q;
- int sum = 0;
- int cnt = 0;
- for (int i = 0; i < n; ++i)
- {
- int cur; in >> cur;
- q.push(cur);
- if (cur % 2 == 0)
- {
- sum += cur;
- cnt++;
- }
- }
- double avg = 1.*sum / cnt;//1.*sum - приведение к типу double
- queue<int> temp;
- while (!q.empty())
- {
- int cur = q.front(); q.pop();
- if (cur > avg)
- out << cur << " ";
- else
- temp.push(cur);
- }
- while (!temp.empty())
- {
- int cur = temp.front(); temp.pop();
- out << cur << " ";
- }
- /*
- пример
- 5
- 1 2 3 4 5
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement