Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main() {
- double a,b,n,sum,step,integr,x,q,res;
- cout << "Введите границы интегрирования (нижняя-верхняя): ";
- cin >> a >> b;
- cout << "Введите количество разбиений: ";
- cin >> n;
- step = (b-a)/(3*n);
- sum=cos(pow(a,2))+cos(pow(b,2));
- q=3*n-1;
- for (int i = 0; i <=q; ++i) {
- x=a+step*i;
- if(i%3==0){
- sum+=2*cos(pow(x,2));
- }
- else{
- sum+=3*cos(pow(x,2));
- }
- }
- sum *=3*step/8;
- cout << "Результат: " << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement