Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main () {
- double a,b,c,d,f,imax,imin;
- cout<< "y(x) = a + b*x + c*x^2 + d*x^3"<<endl;
- cout<< "Select a:"<<endl;
- cin>>a;
- cout<< "Select b:"<<endl;
- cin>>b;
- cout<< "Select c:"<<endl;
- cin>>c;
- cout<< "Select d:"<<endl;
- cin>>d;
- if(a<0)
- cout<<"y(x) = ("<<a<<")"; //i check if the nubmer is //
- else cout<<"y(x) = "<<a;
- if(b<0)
- cout<<" + ("<<b<<")*x";
- else cout<<" + "<<b<<"*x";
- if(c<0)
- cout<<" + ("<<c<<")*x^2" ;
- else cout<<" + "<<b<<"*x";
- if(d<0)
- cout<<" + ("<<d<<")*x^3"<<endl;
- else cout<<" + "<<d<<"*x^3"<<endl;
- cout<<endl;
- for (int i=10;i>=-10;i--) // it is the Y for the grafh
- {
- // //
- imax=i-0.5;
- imin=i+0.5;
- for(int j=-35;j<=35;j++) // it is the X for the grafh
- {
- f= a+b*j+c*j*j+d*j*j*j;
- if(f>=imax&&f<=imin)
- cout<<"*";
- else if( (i==0) && (j==0) && (!(f>=imin-0.5&&f<=imax+0.5)) )
- cout<<"+";
- else if(j==0&&!(f>=imin-0.5&&f<=imax+0.5))
- cout<<"|";
- else if(i==0&&!(f>=imin-0.5&&f<=imax+0.5))
- cout<<"-";
- else
- cout<<" ";
- }
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement