DilyaraL

Untitled

Apr 4th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. void read_and_write(ifstream &f, ofstream&g)
  7. {
  8. int n, a, b;
  9. f >> n;
  10. double s = 0.0;
  11. int* mas = new int[n];
  12. for (int i = 0; i < n; i++)
  13. {
  14. f >> a >> b;
  15. mas[i] = a * b;
  16. s = s + mas[i]*1.0;
  17. }
  18.  
  19. for (int i = 0; i < n; i++)
  20. {
  21. g << mas[i] / s<<endl;
  22. }
  23. delete[]mas;
  24. f.close();
  25. g.close();
  26. }
  27. int main()
  28. {
  29. setlocale(LC_ALL, "Russian");
  30. ifstream in("input.txt");
  31. ofstream out("output.txt");
  32. read_and_write(in, out);
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment