Advertisement
medajibka

3.4

Apr 18th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. double a, b;
  5.  
  6. double function(const double x) {
  7.     return (x + 1) - ((3 * x * x + 4) / x);
  8. }
  9.  
  10. void input() {
  11.     cout << "Enter a: ";
  12.     cin >> a;
  13.  
  14.     cout << "Enter b: ";
  15.     cin >> b;
  16. }
  17.  
  18. int main() {
  19.  
  20.     input();
  21.  
  22.     while (b < a) {
  23.         cout << "Input range again:\n";
  24.         input();
  25.     }
  26.  
  27.     for (double i = a; i <= b; i++) {
  28.         if (i == 0) {
  29.             cout << "\033[1;31mWhen x = 0 there is no solution;\033[0m\n";
  30.         } else {
  31.             cout << "X = " << i << "; Y = " << function(i) << ";\n";
  32.         }
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement