Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <fstream>
- #include <string>
- #include <stack>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- stack<int> s;
- int cnt, sum;
- cnt = sum = 0;
- while (in.peek() != EOF)
- {
- int cur; in >> cur;
- if (cur % 2 == 0)
- {
- s.push(cur);
- cnt++;
- sum += cur;
- }
- }
- out << "AVG : " << 1.*sum / cnt << endl;
- while (!s.empty())
- {
- int cur = s.top(); s.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