Advertisement
kirya_shkolnik

на

Dec 11th, 2020 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. double func(float x)
  6. {
  7.     return (cos(8*x))/sqrt(1+10*x);
  8. }
  9. void RegCikl(float a,float b, float h,float& sum)
  10. {
  11.     double x,y;
  12.     cout<<"Таблица значений функции: "<<endl;
  13.     cout<<"\tx=\ty="<<endl;
  14.     for(x = 0; x < b; x+=h){
  15.         y = func(x);
  16.         cout << "\t" << x << "\t" << y << "\n";
  17.         if(y>0) sum+=y;
  18.     }
  19. }
  20.  
  21. void GetABH(float& a,float& b,float& h)
  22. {
  23.     setlocale(LC_ALL,"rus");
  24.     cout<<"Введите начало отрезка ";
  25.     cin>>a;
  26.     cout<<"Введите конец отрезка ";
  27.     cin>>b;
  28.     cout<<"Введите шаг табулирования ";
  29.     cin>>h;
  30. }
  31. void Put(float sum)
  32. {
  33.     setlocale(LC_ALL,"rus");
  34.     cout<<" Сумма значений функции "<<sum<<endl;
  35. }
  36. int main()
  37. {
  38.     float a,b,h;
  39.     GetABH(a,b,h);
  40.     float sum=0;
  41.     RegCikl(a,b,h,sum);
  42.     Put(sum);
  43.     system("PAUSE");
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement