Advertisement
Oslapas

explain this shit

May 13th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <cmath>
  5. using namespace std;
  6. struct varza
  7. {
  8.     double atskirai;
  9. };
  10. void nulinimas(varza ma[])
  11. {
  12.     for(int i=0;i<100;i++)
  13.     {
  14.         ma[i].atskirai=0;
  15.     }
  16. }
  17. void skaitymas(varza ma[],int &n)
  18. {
  19.     double a,b;
  20.     ifstream fd("lh.txt");
  21.     fd>>n;
  22.     for(int i=0;i<n;i++)
  23.     {
  24.         fd>>a;
  25.         for(int j=0;j<a;j++)
  26.         {
  27.             fd>>b;
  28.             ma[i].atskirai+=1/b;
  29.         }
  30.     }
  31. }
  32. void skaitymasisvedimas(varza ma[],int &n)
  33. {
  34. ofstream fr("varzarez.txt");
  35.     double a,b,c;
  36.     for(int i=0;i<n;i++)
  37.     {
  38.  
  39.         for(int j=0;j<a;j++)
  40.         {
  41.             c+=pow(ma[i].atskirai,-1);
  42.  
  43.         }
  44.     }
  45.     cout<<c<<endl;
  46. }
  47. int main()
  48. {
  49.     int n;
  50.     varza ma[555];
  51.     nulinimas(ma);
  52.     skaitymas(ma,n);
  53.     skaitymasisvedimas(ma,n);
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement