Advertisement
Guest User

Untitled

a guest
May 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. #include "Stack.cpp"
  7. ifstream in("input.txt");
  8. ofstream out("output.txt");
  9. int main()
  10. {
  11. Stack<double> t, t2;
  12. int i, n;
  13. double k = 0, s = 0;
  14. while (in >> i)
  15. {
  16. t.Push(i);
  17. }
  18. in.close();
  19. while (!t.Empty())
  20. {
  21. n = t.Pop();
  22. if (n % 2 == 0)
  23. {
  24. k++;
  25. s += n;
  26. t2.Push(n);
  27. }
  28. }
  29. double ss = 0;
  30. ss = s / k;
  31. t2.Push(ss);
  32. while (!t2.Empty())
  33. {
  34. cout << t2.Pop() << ' ';
  35. }
  36. //out << endl;
  37. //out << "sredarf = " << ss;
  38. system("pause");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement