Advertisement
Sanlover

Untitled

Nov 18th, 2021
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double funcValue(const double& point) {
  5.   return (point * point - 5.0 * point + 7.0) /
  6.          sqrt(3.0 * point * point * point + 1.0);
  7. }
  8.  
  9. int main() {
  10.   int N;
  11.   cout << "Etner N: ";
  12.   cin >> N;
  13.   if (N <= 0) {
  14.     cout << "N must be positive";
  15.     return 0;
  16.   }
  17.  
  18.   int min, max;
  19.   double temp;
  20.  
  21.   cout << "Enter values:" << endl << "1) ";
  22.   cin >> temp;
  23.   min = max = temp;
  24.   for (int i = 1; i < N; i++) {
  25.     cout << i + 1 << ") ";
  26.     cin >> temp;
  27.     double resonse = funcValue(temp);
  28.     if (resonse > funcValue(max)) {
  29.       max = temp;
  30.     }
  31.     if (funcValue(min) > resonse) {
  32.       min = temp;
  33.     }
  34.   }
  35.   cout << "Point with max value is " << max << endl;
  36.   cout << "Point with min value is " << min << endl;
  37.   return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement