Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <fstream>
- #include <string>
- #include <queue>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- queue<int> q;
- int cnt, sum;
- cnt = sum = 0;
- while (in.peek() != EOF)
- {
- int cur; in >> cur;
- if (cur % 2 == 0)
- {
- q.push(cur);
- cnt++;
- sum += cur;
- }
- }
- out << "AVG : " << 1.*sum / cnt << endl;
- while (!q.empty())
- {
- int cur = q.front(); q.pop();
- out << cur << " ";
- }
- //
- // 12 54 3 51 8 4 3 84 2 42 3 4 5 2
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement