Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- struct varza
- {
- double atskirai;
- };
- void nulinimas(varza ma[])
- {
- for(int i=0;i<100;i++)
- {
- ma[i].atskirai=0;
- }
- }
- void skaitymas(varza ma[],int &n)
- {
- double a,b;
- ifstream fd("lh.txt");
- fd>>n;
- for(int i=0;i<n;i++)
- {
- fd>>a;
- for(int j=0;j<a;j++)
- {
- fd>>b;
- ma[i].atskirai+=1/b;
- }
- }
- }
- void skaitymasisvedimas(varza ma[],int &n)
- {
- ofstream fr("varzarez.txt");
- double a,b,c;
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<a;j++)
- {
- c+=pow(ma[i].atskirai,-1);
- }
- }
- cout<<c<<endl;
- }
- int main()
- {
- int n;
- varza ma[555];
- nulinimas(ma);
- skaitymas(ma,n);
- skaitymasisvedimas(ma,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement