Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double calkowanieTrapezami(double dolnaGranica, double gornaGranica, int liczbaKrokow)
- {
- double deltax=(gornaGranica - dolnaGranica)/liczbaKrokow;
- double k=0;
- cout<<deltax<<endl;
- for(int i=0 ; i<liczbaKrokow ; i++)
- {
- k += (cos(dolnaGranica+(deltax)*i)*cos(dolnaGranica+(deltax)*i)+1+cos(dolnaGranica+(deltax)*(i+1))*cos(dolnaGranica+(deltax)*(i+1))+1);
- cout<<i<<": "<<k<<endl;
- }
- return (k/liczbaKrokow);
- }
- int main()
- {
- cout << "Hello world!" << endl;
- cout<< calkowanieTrapezami(0,6.28,4);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement