Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double f(float x) {
- if (x == 1 || x == -1) {
- return 1;
- }
- if (x >= 0 && x != 1) {
- return (-1 / (1 - x));
- }
- if (x < 0 && x != -1) {
- return (1 / (1 + x));
- }
- }
- int main() {
- float a, b, h, x;
- cin >> a >> b >> h;
- cout << "x\tf(x)\n";
- for (x = a; x <= b; x += h) {
- cout << x << "\t";
- cout << f(x);
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement