Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- #include <iomanip>
- using namespace std;
- void read_and_write(ifstream &f, ofstream&g)
- {
- int n, a, b;
- f >> n;
- double s = 0.0;
- int* mas = new int[n];
- for (int i = 0; i < n; i++)
- {
- f >> a >> b;
- mas[i] = a * b;
- s = s + mas[i]*1.0;
- }
- for (int i = 0; i < n; i++)
- {
- g << mas[i] / s<<endl;
- }
- delete[]mas;
- f.close();
- g.close();
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- ifstream in("input.txt");
- ofstream out("output.txt");
- read_and_write(in, out);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment