Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ofstream ofs("output.txt");
  10. ifstream ifs("input.txt");
  11.  
  12. int c, g;
  13. ifs >> c;
  14.  
  15. int *count = new int[c];
  16. for (int i = 0; i < c; i++)
  17. ifs >> count[i];
  18.  
  19. float res = 0;
  20. for (int i = 0; i < c; i++)
  21. {
  22. res = 0; g = 0;
  23. for (int h = 0; h < count[i]; h++)
  24. {
  25. ifs >> g;
  26. res += g;
  27. }
  28.  
  29. ofs << round(res / count[i]) << " ";
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement