kirya_shkolnik

C++ - Антон - 4

Jan 23rd, 2021 (edited)
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. double RegCikl(double a, double b, double h, double& count) {
  2.     double x, y;
  3.     double Sum = 0;
  4.     int n = ceil((b-a)/h)+1;
  5.     for (int i = 1; i <= n; ++i) {
  6.         x = a+(i-1)*h;
  7.         y = exp(3*x) - cos(x*x);
  8.         if(y < 0.0){
  9.             Sum += y;
  10.             count++;
  11.         }
  12.     }
  13.     return Sum;
  14. }
  15.  
  16.  
  17.  
  18. int main()
  19. {
  20.     double a,b,h, count = 0;
  21.     cin >> a >> b >> h;
  22.     double Sum = RegCikl(a,b,h, count);
  23.     cout << Sum << " " << count;
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment