Advertisement
kirya_shkolnik

Забирай свое говно

Dec 12th, 2020
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void Get(float& a,float& b,float& h1,float& c,float& d,float& h2)
  5. {
  6.     setlocale(LC_ALL,"rus");
  7.     cout<<"Введите нижнюю границу отрезка изменения X: ";
  8.     cin>>a;
  9.     cout<<"Введите верхнюю границу отрезка изменения X: ";
  10.     cin>>b;
  11.     cout<<"Введите шаг изменения X: ";
  12.     cin>>h1;
  13.     cout<<"Введите нижнюю границу отрезка изменения Y: ";
  14.     cin>>c;
  15.     cout<<"Введите верхнюю границу отрезка изменения Y: ";
  16.     cin>>d;
  17.     cout<<"Введите шаг изменения Y: ";
  18.     cin>>h2;
  19. }
  20.  
  21. void Put(float minZ)
  22. {
  23.     setlocale(LC_ALL,"rus");
  24.     cout<<endl<<"Наименьшее значение функции: "<<minZ<<endl;
  25. }
  26.  float f(float x,float y)
  27. {
  28.     return (x-y-x/y);
  29. }
  30. float Calc(float a, float b, float h1, float c, float d, float h2){
  31.     setlocale(LC_ALL,"rus");
  32.     float x,y,z;
  33.     float minZ = -3.402823466E+38;
  34.     cout<<endl<<"Таблица значений функции"<<endl;
  35.     cout<<"\tx\ty\tz"<<endl;
  36.     for(float x = a; x<=b; x+=h1){
  37.         for(float y = c; y<=d; y+=h2){
  38.             z = f(x,y);
  39.             cout << "\t" << x << "\t" << y << "\t" << z << "\n";
  40.             if(z < minZ) minZ = z;
  41.         }
  42.     }
  43.     return minZ;
  44. }
  45.  
  46. int main()
  47. {
  48.     float a,b,h1,c,d,h2,minZ;
  49.     Get(a,b,h1,c,d,h2);
  50.     minZ = Calc(a, b, h1, c, d, h2);
  51.     Put(minZ);
  52.     system("PAUSE");
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement