SHARE
TWEET

Untitled

a guest Jan 28th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _USE_MATH_DEFINES
  2. #include <cmath>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. double func(double a, double b, double c, double x)
  8. {
  9.     double f;
  10.     if(x<0 && b!=0)
  11.     {
  12.         f = -(2*x - c)/(c*x - a);
  13.     }
  14.     else
  15.     {
  16.         if(x>0 && b==0)
  17.         {
  18.             f = (x - a) / (x - c);
  19.         }
  20.         else
  21.         {
  22.             f = -x/c + -c/(2*x);
  23.         }
  24.     }
  25.     int ac = (int) a;
  26.     int bc = (int) c;
  27.     int cc = (int) c;
  28.     if ((~(ac | bc)) & (~(ac | cc)))
  29.         return f;
  30.     else
  31.         return (int) f;
  32. }
  33.  
  34. int main()
  35. {
  36.     double a, b, c, xStart, xEnd, xDelta;
  37.     cin>>a>>b>>c>>xStart>>xEnd>>xDelta;
  38.     for(double i=xStart; i<=xEnd; i+=xDelta)
  39.     {
  40.         double res = func(a, b, c, i);
  41.         cout<<"f("<<i<<")="<<res<<"\n";
  42.     }
  43.     return 0;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top