Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <cmath>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- double func(double a, double b, double c, double x)
- {
- double f;
- if(x<0 && b!=0)
- {
- f = -(2*x - c)/(c*x - a);
- }
- else
- {
- if(x>0 && b==0)
- {
- f = (x - a) / (x - c);
- }
- else
- {
- f = -x/c + -c/(2*x);
- }
- }
- int ac = (int) a;
- int bc = (int) c;
- int cc = (int) c;
- if ((~(ac | bc)) & (~(ac | cc)))
- return f;
- else
- return (int) f;
- }
- int main()
- {
- double a, b, c, xStart, xEnd, xDelta;
- cin>>a>>b>>c>>xStart>>xEnd>>xDelta;
- for(double i=xStart; i<=xEnd; i+=xDelta)
- {
- double res = func(a, b, c, i);
- cout<<"f("<<i<<")="<<res<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement