Advertisement
myloyo

3.6.13

Nov 6th, 2022 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. double f(float x) {
  6.     if (x == 1 || x == -1) {
  7.         return 1;
  8.     }
  9.     if (x >= 0 && x != 1) {
  10.         return (-1 / (1 - x));
  11.     }
  12.     if (x < 0 && x != -1) {
  13.         return (1 / (1 + x));
  14.     }
  15. }
  16.  
  17. int main() {
  18.     float a, b, h, x;
  19.     cin >> a >> b >> h;
  20.     cout << "x\tf(x)\n";
  21.     for (x = a; x <= b; x += h) {
  22.         cout << x << "\t";
  23.         cout << f(x);
  24.         cout << endl;
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement