Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- list<int> l;
- list<int> even_l;
- int cnt = 0;
- long long sum = 0;
- while (in.peek() != EOF)
- {
- int cur; in >> cur;
- l.push_back(cur);
- }
- while (!l.empty())
- {
- int cur = l.front();
- l.pop_front();
- if (cur % 2 == 0)
- {
- cnt++;
- sum += cur;
- even_l.push_back(cur);
- }
- }
- out << "count of even : " << cnt << "\n";
- out << "sum of even : " << sum << "\n";
- out << "AVG : " << sum * 1.0 / cnt;
- //even_l - лист с четными числами
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement