Advertisement
kirya_shkolnik

Зимовец - 4

Feb 24th, 2021
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. void RegCikl(double a, double b, double h, double& max, double& min ){
  7.     double x,y;
  8.     int n = ceil((b-a)/h)+1;
  9.     for (int i = 1; i<=n; ++i){
  10.         x = a+(i-1)*h;
  11.         y = exp(3*x)-x*x;
  12.         if(y>max) max = y;
  13.         if(y<min) min = y;
  14.     }
  15. }
  16.  
  17. int main() {
  18.     double a,b,h;
  19.     double max = -1.7e308, min = 1.7e308;
  20.     cin >> a >> b >> h;
  21.     RegCikl(a,b,h,max, min);
  22.     cout << max <<min;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement